Search in sources :

Example 1 with Activity

use of com.epam.ta.reportportal.entity.activity.Activity in project commons-dao by reportportal.

the class ActivityRepositoryTest method deleteTest.

@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
void deleteTest() {
    final Activity activity = repository.findById(1L).get();
    repository.delete(activity);
    assertEquals(ACTIVITIES_COUNT - 1, repository.findAll().size());
}
Also used : Activity(com.epam.ta.reportportal.entity.activity.Activity) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 2 with Activity

use of com.epam.ta.reportportal.entity.activity.Activity in project commons-dao by reportportal.

the class ActivityRepositoryTest method findByFilterWithSortingAndLimit.

@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
void findByFilterWithSortingAndLimit() {
    List<Activity> activities = repository.findByFilterWithSortingAndLimit(defaultFilter(), Sort.by(Sort.Direction.DESC, CRITERIA_CREATION_DATE), 2);
    assertEquals(2, activities.size());
    final LocalDateTime first = activities.get(0).getCreatedAt();
    final LocalDateTime second = activities.get(1).getCreatedAt();
    assertTrue(first.isBefore(second) || first.isEqual(second));
}
Also used : LocalDateTime(java.time.LocalDateTime) Activity(com.epam.ta.reportportal.entity.activity.Activity) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 3 with Activity

use of com.epam.ta.reportportal.entity.activity.Activity in project commons-dao by reportportal.

the class ActivityRepositoryTest method deleteModifiedLaterAgo.

// Custom Repositories
@Test
void deleteModifiedLaterAgo() {
    Duration period = Duration.ofDays(10);
    LocalDateTime bound = LocalDateTime.now().minus(period);
    repository.deleteModifiedLaterAgo(1L, period);
    List<Activity> all = repository.findAll();
    all.stream().filter(a -> a.getProjectId().equals(1L)).forEach(a -> assertTrue(a.getCreatedAt().isAfter(bound)));
}
Also used : LocalDateTime(java.time.LocalDateTime) Comparators(com.google.common.collect.Comparators) CRITERIA_PROJECT_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID) java.util(java.util) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LocalDateTime(java.time.LocalDateTime) Activity(com.epam.ta.reportportal.entity.activity.Activity) Autowired(org.springframework.beans.factory.annotation.Autowired) ActivityCriteriaConstant(com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant) CRITERIA_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Duration(java.time.Duration) Sort(org.springframework.data.domain.Sort) BaseTest(com.epam.ta.reportportal.BaseTest) Lists(org.apache.commons.compress.utils.Lists) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Timestamp(java.sql.Timestamp) PageRequest(org.springframework.data.domain.PageRequest) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) HistoryField(com.epam.ta.reportportal.entity.activity.HistoryField) Page(org.springframework.data.domain.Page) Sql(org.springframework.test.context.jdbc.Sql) ActivityDetails(com.epam.ta.reportportal.entity.activity.ActivityDetails) Test(org.junit.jupiter.api.Test) CRITERIA_USER(com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER) Assertions(org.junit.jupiter.api.Assertions) Activity(com.epam.ta.reportportal.entity.activity.Activity) Duration(java.time.Duration) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 4 with Activity

use of com.epam.ta.reportportal.entity.activity.Activity in project commons-dao by reportportal.

the class ActivityRepositoryTest method findByCreationDate.

@Test
void findByCreationDate() {
    LocalDateTime to = LocalDateTime.now();
    LocalDateTime from = to.minusDays(7);
    final List<Activity> activities = repository.findByFilter(new Filter(Activity.class, Condition.BETWEEN, false, Timestamp.valueOf(from).getTime() + "," + Timestamp.valueOf(to).getTime(), CRITERIA_CREATION_DATE));
    assertNotNull(activities);
    assertTrue(!activities.isEmpty());
    activities.forEach(it -> assertTrue(it.getCreatedAt().isBefore(to) && it.getCreatedAt().isAfter(from)));
}
Also used : LocalDateTime(java.time.LocalDateTime) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Activity(com.epam.ta.reportportal.entity.activity.Activity) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 5 with Activity

use of com.epam.ta.reportportal.entity.activity.Activity in project commons-dao by reportportal.

the class ActivityRepositoryTest method findByEntityType.

@Test
void findByEntityType() {
    final List<Activity> activities = repository.findByFilter(new Filter(Activity.class, Condition.EQUALS, false, "launch", CRITERIA_ENTITY));
    assertNotNull(activities);
    assertTrue(!activities.isEmpty());
    activities.forEach(it -> assertEquals(Activity.ActivityEntityType.LAUNCH.getValue(), it.getActivityEntityType()));
}
Also used : Filter(com.epam.ta.reportportal.commons.querygen.Filter) Activity(com.epam.ta.reportportal.entity.activity.Activity) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

Activity (com.epam.ta.reportportal.entity.activity.Activity)12 BaseTest (com.epam.ta.reportportal.BaseTest)11 Test (org.junit.jupiter.api.Test)11 Filter (com.epam.ta.reportportal.commons.querygen.Filter)6 LocalDateTime (java.time.LocalDateTime)4 ActivityDetails (com.epam.ta.reportportal.entity.activity.ActivityDetails)3 PageRequest (org.springframework.data.domain.PageRequest)2 Condition (com.epam.ta.reportportal.commons.querygen.Condition)1 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)1 ActivityCriteriaConstant (com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant)1 CRITERIA_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_ID)1 CRITERIA_PROJECT_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID)1 CRITERIA_USER (com.epam.ta.reportportal.commons.querygen.constant.UserCriteriaConstant.CRITERIA_USER)1 HistoryField (com.epam.ta.reportportal.entity.activity.HistoryField)1 Comparators (com.google.common.collect.Comparators)1 Timestamp (java.sql.Timestamp)1 Duration (java.time.Duration)1 java.util (java.util)1 Lists (org.apache.commons.compress.utils.Lists)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1