<commit_before>package com.drumonii.loltrollbuild.batch;

import com.drumonii.loltrollbuild.batch.champions.ChampionsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.items.ItemsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.maps.MapsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.summonerSpells.SummonerSpellsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.versions.VersionsRetrievalJobConfig;
import com.drumonii.loltrollbuild.model.Version;
import com.drumonii.loltrollbuild.riot.service.*;
import com.drumonii.loltrollbuild.test.batch.BatchTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.*;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;

import static com.drumonii.loltrollbuild.batch.scheduling.RetrievalJobsScheduling.LATEST_PATCH_KEY;
import static com.drumonii.loltrollbuild.config.Profiles.TESTING;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;

@RunWith(SpringRunner.class)
@BatchTest({ AllRetrievalsJobConfig.class, ChampionsRetrievalJobConfig.class, ItemsRetrievalJobConfig.class,
		MapsRetrievalJobConfig.class, SummonerSpellsRetrievalJobConfig.class, VersionsRetrievalJobConfig.class})
@ActiveProfiles({ TESTING })
public class AllRetrievalsJobConfigTest {

	@MockBean
	private VersionsService versionsService;

	@MockBean
	private MapsService mapsService;

	@MockBean
	private SummonerSpellsService summonerSpellsService;

	@MockBean
	private ChampionsService championsService;

	@MockBean
	private ItemsService itemsService;

	@Autowired
	private JobLauncherTestUtils jobLauncherTestUtils;

	@Before
	public void before() {
		given(versionsService.getLatestVersion()).willReturn(new Version("8.1.1"));

		given(mapsService.getMaps()).willReturn(new ArrayList<>());

		given(summonerSpellsService.getSummonerSpells()).willReturn(new ArrayList<>());

		given(championsService.getChampions()).willReturn(new ArrayList<>());

		given(itemsService.getItems()).willReturn(new ArrayList<>());
	}

	@Test
	public void runsAllRetrievalJobs() throws Exception {
		JobParameters jobParameters = jobLauncherTestUtils.getJob().getJobParametersIncrementer()
				.getNext(new JobParameters());
		assertThat(jobParameters.getParameters()).containsKey(LATEST_PATCH_KEY);

		JobExecution jobExecution = jobLauncherTestUtils.launchJob(jobParameters);
		assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED);
		assertThat(jobExecution.getJobParameters().getString(LATEST_PATCH_KEY)).isNotNull();
		assertThat(jobExecution.getStepExecutions()).extracting(StepExecution::getStepName)
				.containsExactly("versionsRetrievalJobStep", "mapsRetrievalJobStep", "summonerSpellsRetrievalJobStep",
						"championsRetrievalJobStep", "itemsRetrievalJobStep");
	}

	@TestConfiguration<commit_msg>Assert latest version of job parameters in all retrievals job<commit_after>package com.drumonii.loltrollbuild.batch;

import com.drumonii.loltrollbuild.batch.champions.ChampionsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.items.ItemsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.maps.MapsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.summonerSpells.SummonerSpellsRetrievalJobConfig;
import com.drumonii.loltrollbuild.batch.versions.VersionsRetrievalJobConfig;
import com.drumonii.loltrollbuild.model.Version;
import com.drumonii.loltrollbuild.riot.service.*;
import com.drumonii.loltrollbuild.test.batch.BatchTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.*;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;

import static com.drumonii.loltrollbuild.batch.scheduling.RetrievalJobsScheduling.LATEST_PATCH_KEY;
import static com.drumonii.loltrollbuild.config.Profiles.TESTING;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;

@RunWith(SpringRunner.class)
@BatchTest({ AllRetrievalsJobConfig.class, ChampionsRetrievalJobConfig.class, ItemsRetrievalJobConfig.class,
		MapsRetrievalJobConfig.class, SummonerSpellsRetrievalJobConfig.class, VersionsRetrievalJobConfig.class})
@ActiveProfiles({ TESTING })
public class AllRetrievalsJobConfigTest {

	@MockBean
	private VersionsService versionsService;

	@MockBean
	private MapsService mapsService;

	@MockBean
	private SummonerSpellsService summonerSpellsService;

	@MockBean
	private ChampionsService championsService;

	@MockBean
	private ItemsService itemsService;

	@Autowired
	private JobLauncherTestUtils jobLauncherTestUtils;

	private Version latestVersion = new Version("8.1.1");

	@Before
	public void before() {
		given(versionsService.getLatestVersion()).willReturn(latestVersion);

		given(mapsService.getMaps()).willReturn(new ArrayList<>());

		given(summonerSpellsService.getSummonerSpells()).willReturn(new ArrayList<>());

		given(championsService.getChampions()).willReturn(new ArrayList<>());

		given(itemsService.getItems()).willReturn(new ArrayList<>());
	}

	@Test
	public void runsAllRetrievalJobs() throws Exception {
		JobParameters jobParameters = jobLauncherTestUtils.getJob().getJobParametersIncrementer()
				.getNext(new JobParameters());
		assertThat(jobParameters.getParameters()).containsKey(LATEST_PATCH_KEY);

		JobExecution jobExecution = jobLauncherTestUtils.launchJob(jobParameters);
		assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.COMPLETED);
		assertThat(jobExecution.getJobParameters().getString(LATEST_PATCH_KEY)).isEqualTo(latestVersion.getPatch());
		assertThat(jobExecution.getStepExecutions()).extracting(StepExecution::getStepName)
				.containsExactly("versionsRetrievalJobStep", "mapsRetrievalJobStep", "summonerSpellsRetrievalJobStep",
						"championsRetrievalJobStep", "itemsRetrievalJobStep");
	}

	@TestConfiguration
{'fraction_non_alphanumeric': 0.09954418467872372, 'fraction_numerical': 0.0011762976032936333, 'mean_word_length': 8.241847826086957, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6963958', 'n_tokens_mistral': 2146, 'n_tokens_neox': 2055, 'n_words': 274}