package com.drumonii.loltrollbuild.repository;

import com.drumonii.loltrollbuild.BaseSpringTestRunner;
import com.drumonii.loltrollbuild.model.BatchJobExecution;
import com.drumonii.loltrollbuild.model.BatchJobInstance;
import com.drumonii.loltrollbuild.model.BatchStepExecution;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.junit.Test;

import java.time.LocalDateTime;

import static org.assertj.core.api.Assertions.assertThat;

public class BatchStepExecutionsRepositoryTest extends BaseSpringTestRunner {

	@Test
	public void findByJobInstanceId() throws Exception {
		BatchJobInstance jobInstance = new BatchJobInstance();
		jobInstance.setName(RandomStringUtils.randomAlphabetic(7));
		jobInstance.setKey(RandomStringUtils.randomAlphabetic(10));
		jobInstance = batchJobInstancesRepository.save(jobInstance);

		BatchJobExecution jobExecution = new BatchJobExecution();
		jobExecution.setCreateTime(LocalDateTime.now());
		jobExecution.setJobInstance(jobInstance);
		jobExecution = batchJobExecutionsRepository.save(jobExecution);

		BatchStepExecution stepExecution = new BatchStepExecution();
		stepExecution.setVersion(RandomUtils.nextLong());
		stepExecution.setName(RandomStringUtils.randomAlphabetic(10));
		stepExecution.setStartTime(LocalDateTime.now());
		stepExecution.setJobExecution(jobExecution);
		batchStepExecutionsRepository.save(stepExecution);

		assertThat(batchStepExecutionsRepository.findByJobInstanceId(jobInstance.getId())).isNotEmpty();
		assertThat(batchStepExecutionsRepository.findByJobInstanceId(-1)).isEmpty();
	}

}
@@ -45,64 +45,8 @@
 y;%0A%0A
-import com.drumonii.loltrollbuild.BaseSpringTestRunner;%0A
 impo
@@ -222,59 +222,8 @@
 on;%0A
-import org.apache.commons.lang3.RandomStringUtils;%0A
 impo
@@ -290,178 +290,787 @@
 st;%0A
-%0Aimport java.time.LocalDateTime;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0Apublic class BatchStepExecutionsRepositoryTest extends BaseSpringTestRunner %7B
+import org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;%0Aimport org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;%0Aimport org.springframework.test.context.ActiveProfiles;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport java.time.LocalDateTime;%0A%0Aimport static com.drumonii.loltrollbuild.config.Profiles.TESTING;%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0A@RunWith(SpringRunner.class)%0A@DataJpaTest%0A@ActiveProfiles(TESTING)%0Apublic class BatchStepExecutionsRepositoryTest %7B%0A%0A%09@Autowired%0A%09private BatchStepExecutionsRepository batchStepExecutionsRepository;%0A%0A%09@Autowired%0A%09private TestEntityManager testEntityManager;
 %0A%0A%09@
@@ -1112,25 +1112,8 @@
 Id()
- throws Exception
  %7B%0A%09
@@ -1194,158 +1194,117 @@
 ame(
-RandomStringUtils.randomAlphabetic(7));%0A%09%09jobInstance.setKey(RandomStringUtils.randomAlphabetic(10));%0A%09%09jobInstance = batchJobInstancesRepository.save
+%22jobInstanceName%22);%0A%09%09jobInstance.setKey(%22jobInstanceKey%22);%0A%09%09jobInstance = testEntityManager.persistAndFlush
 (job
@@ -1491,41 +1491,41 @@
 n = 
-batchJobExecutionsRepository.save
+testEntityManager.persistAndFlush
 (job
@@ -1680,46 +1680,15 @@
 ame(
-RandomStringUtils.randomAlphabetic(10)
+%22step1%22
 );%0A%09
@@ -1790,42 +1790,41 @@
 ;%0A%09%09
-batchStepExecutionsRepository.save
+testEntityManager.persistAndFlush
 (ste

Convert BatchStepExecutionsRepositoryTest to @DataJpaTest