Search in sources :

Example 1 with Cluster

use of com.epam.ta.reportportal.entity.cluster.Cluster in project commons-dao by reportportal.

the class ClusterRepositoryTest method shouldSaveClusterTestItems.

@Test
void shouldSaveClusterTestItems() {
    final Cluster cluster = clusterRepository.findAllByLaunchId(LAUNCH_ID).get(0);
    final int inserted = clusterRepository.saveClusterTestItems(cluster, Set.of(1L, 2L));
    assertEquals(2, inserted);
}
Also used : Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 2 with Cluster

use of com.epam.ta.reportportal.entity.cluster.Cluster in project commons-dao by reportportal.

the class ClusterRepositoryTest method shouldDeleteClusterTestItemsByProjectId.

@Test
void shouldDeleteClusterTestItemsByProjectId() {
    final Cluster cluster = clusterRepository.findByIndexIdAndLaunchId(1L, 1L).get();
    clusterRepository.saveClusterTestItems(cluster, Set.of(1L));
    final int removed = clusterRepository.deleteClusterTestItemsByProjectId(1L);
    assertEquals(1, removed);
}
Also used : Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 3 with Cluster

use of com.epam.ta.reportportal.entity.cluster.Cluster in project commons-dao by reportportal.

the class ClusterRepositoryTest method shouldDeleteByLaunchId.

@Test
void shouldDeleteByLaunchId() {
    final int removed = clusterRepository.deleteAllByLaunchId(LAUNCH_ID);
    assertEquals(3, removed);
    final Pageable pageable = PageRequest.of(0, 3, Sort.by(Sort.Order.by(CRITERIA_ID)));
    final Page<Cluster> clusters = clusterRepository.findAllByLaunchId(LAUNCH_ID, pageable);
    assertTrue(clusters.isEmpty());
}
Also used : Pageable(org.springframework.data.domain.Pageable) Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 4 with Cluster

use of com.epam.ta.reportportal.entity.cluster.Cluster in project commons-dao by reportportal.

the class ClusterRepositoryTest method insertClusters.

@BeforeEach
void insertClusters() {
    final List<Cluster> clusters = LongStream.range(CLUSTER_ID_START_VALUE, CLUSTER_ID_END_VALUE).mapToObj(id -> {
        final Cluster cluster = new Cluster();
        cluster.setIndexId(id);
        cluster.setProjectId(PROJECT_ID);
        cluster.setLaunchId(LAUNCH_ID);
        cluster.setMessage("Message");
        return cluster;
    }).collect(Collectors.toList());
    clusterRepository.saveAll(clusters);
    clusters.stream().map(Cluster::getId).forEach(savedIds::add);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) BaseTest(com.epam.ta.reportportal.BaseTest) LongStream(java.util.stream.LongStream) Autowired(org.springframework.beans.factory.annotation.Autowired) PageRequest(org.springframework.data.domain.PageRequest) Set(java.util.Set) Page(org.springframework.data.domain.Page) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) CRITERIA_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID) AfterEach(org.junit.jupiter.api.AfterEach) List(java.util.List) Assertions(org.junit.jupiter.api.Assertions) Optional(java.util.Optional) Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with Cluster

use of com.epam.ta.reportportal.entity.cluster.Cluster in project commons-dao by reportportal.

the class ClusterRepositoryTest method shouldFindByLaunchId.

@Test
void shouldFindByLaunchId() {
    final Pageable pageable = PageRequest.of(0, 3, Sort.by(Sort.Order.by(CRITERIA_ID)));
    final Page<Cluster> clusters = clusterRepository.findAllByLaunchId(LAUNCH_ID, pageable);
    assertFalse(clusters.isEmpty());
    assertEquals(3, clusters.getContent().size());
    clusters.getContent().forEach(cluster -> assertEquals(LAUNCH_ID, cluster.getLaunchId()));
}
Also used : Pageable(org.springframework.data.domain.Pageable) Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

BaseTest (com.epam.ta.reportportal.BaseTest)8 Cluster (com.epam.ta.reportportal.entity.cluster.Cluster)8 Test (org.junit.jupiter.api.Test)8 Pageable (org.springframework.data.domain.Pageable)4 CRITERIA_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 LongStream (java.util.stream.LongStream)1 AfterEach (org.junit.jupiter.api.AfterEach)1 Assertions (org.junit.jupiter.api.Assertions)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Page (org.springframework.data.domain.Page)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1 Sql (org.springframework.test.context.jdbc.Sql)1