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