class DatabasePopulator {

    public void populateTestData() {

        if (!isDatabaseAvailable(jdbcTemplate)) {
            return;                             // return so that the application context can start at least
        }

        // create statistics for two companies (latest)
        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();

        // create projects for galanto
        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();
            }
        }

        // create contributors for galanto
        for (int i = 0; i < 2; i++) {
            new ContributorBuilder(contributorRepository)
                .organizationName("galanto")
                .save();
        }
    }

    @Autowired public  DatabasePopulator(StatisticsRepository statisticsRepository,
                             ProjectRepository projectRepository,
                             ContributorRepository contributorRepository,
                             JdbcTemplate jdbcTemplate);

}