Search in sources :

Example 6 with Activity

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

the class ActivityRepositoryTest method createTest.

@Test
void createTest() {
    final Activity entity = generateActivity();
    final Activity saved = repository.save(entity);
    entity.setId(saved.getId());
    final List<Activity> all = repository.findAll();
    assertEquals(saved, entity);
    assertEquals(ACTIVITIES_COUNT + 1, all.size());
    assertTrue(all.contains(entity));
}
Also used : Activity(com.epam.ta.reportportal.entity.activity.Activity) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 7 with Activity

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

the class ActivityRepositoryTest method updateTest.

@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
void updateTest() {
    Activity activity = repository.findById(1L).get();
    final LocalDateTime now = LocalDateTime.now();
    final ActivityDetails details = generateDetails();
    final String action = "test";
    activity.setCreatedAt(now);
    activity.setAction(action);
    activity.setDetails(details);
    final Activity updated = repository.save(activity);
    assertEquals(now, updated.getCreatedAt());
    assertThat(updated.getDetails()).isEqualToIgnoringGivenFields(details, "mapper");
    assertEquals(action, updated.getAction());
}
Also used : LocalDateTime(java.time.LocalDateTime) ActivityDetails(com.epam.ta.reportportal.entity.activity.ActivityDetails) Activity(com.epam.ta.reportportal.entity.activity.Activity) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 8 with Activity

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

the class ActivityRepositoryTest method generateActivity.

private Activity generateActivity() {
    Activity activity = new Activity();
    activity.setActivityEntityType(Activity.ActivityEntityType.DEFECT_TYPE.getValue());
    activity.setAction("create_defect");
    activity.setObjectId(11L);
    activity.setCreatedAt(LocalDateTime.now());
    activity.setProjectId(1L);
    activity.setUserId(1L);
    activity.setDetails(new ActivityDetails("test defect name"));
    return activity;
}
Also used : ActivityDetails(com.epam.ta.reportportal.entity.activity.ActivityDetails) Activity(com.epam.ta.reportportal.entity.activity.Activity)

Example 9 with Activity

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

the class ActivityRepositoryTest method sortingByJoinedColumnTest.

@Test
void sortingByJoinedColumnTest() {
    PageRequest pageRequest = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, CRITERIA_USER));
    Page<Activity> activitiesPage = repository.findByFilter(defaultFilter(), pageRequest);
    assertTrue(Comparators.isInOrder(activitiesPage.getContent(), Comparator.comparing(Activity::getUsername).reversed()));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Activity(com.epam.ta.reportportal.entity.activity.Activity) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 10 with Activity

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

the class ActivityRepositoryTest method findByProjectId.

@Test
void findByProjectId() {
    final List<Activity> activities = repository.findByFilter(new Filter(Activity.class, Condition.EQUALS, false, String.valueOf(1), CRITERIA_PROJECT_ID));
    assertNotNull(activities);
    assertTrue(!activities.isEmpty());
    activities.forEach(it -> assertEquals(1L, (long) it.getProjectId()));
}
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