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());
}
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));
}
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)));
}
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)));
}
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()));
}
Aggregations