DatabasePopulator { public void populateTestData() { if (!isDatabaseAvailable(jdbcTemplate)) { return; } new StatisticsBuilder(statisticsRepository) .organizationName("galanto") .publicProjectCount(34) .allStarsCount(54) .allForksCount(110) .days(1) .save(); new StatisticsBuilder(statisticsRepository) .organizationName("galanto-italic") .publicProjectCount(56) .allStarsCount(93) .allForksCount(249) .days(1) .save(); List<Date> snapshots = Stream .generate(BuilderUtil::randomDate) .limit(100) .collect(Collectors.toList()); for (int i = 0; i < 10; i++) { Long gitHubProjectId = freshId(); String name = randomProjectName(); String language = randomLanguage(); for (Date snapshot : snapshots) { new ProjectBuilder(projectRepository) .organizationName("galanto") .name(name) .gitHubProjectId(gitHubProjectId) .primaryLanguage(language) .snapshotDate(snapshot) .forksCount(random(1, 4)) .starsCount(random(1, 10)) .commitsCount(random(1, 1000)) .contributorsCount(random(1, 1000)) .score(random(1, 100)) .save(); } } for (int i = 0; i < 2; i++) { new ContributorBuilder(contributorRepository) .organizationName("galanto") .save(); } } @Autowired  DatabasePopulator(StatisticsRepository statisticsRepository,
                             ProjectRepository projectRepository,
                             ContributorRepository contributorRepository,
                             JdbcTemplate jdbcTemplate); void populateTestData();  }
@Test public void testPopulateTestData() { populator.populateTestData(); List<Statistics> galantos = statisticsRepository.findByOrganizationName("galanto"); assertEquals(1, galantos.size()); List<Project> projects = projectRepository.findProjects("galanto", Optional.empty(), Optional.empty()); assertFalse(projects.isEmpty()); List<Contributor> contributors = contributorRepository.findContributorsByOrganizationAndDate(Collections.singleton("galanto"), new Date(0), new Date()); assertFalse(contributors.isEmpty()); }