11package com .codedifferently .lesson9 ;
22
3- import com .codedifferently .lesson9 .generator .SampleFileGenerator ;
43import java .io .File ;
54import java .nio .file .Paths ;
5+ import java .util .List ;
6+
7+ import org .springframework .beans .factory .annotation .Autowired ;
68import org .springframework .boot .CommandLineRunner ;
79import org .springframework .boot .SpringApplication ;
810import org .springframework .boot .autoconfigure .SpringBootApplication ;
911import org .springframework .context .annotation .Configuration ;
1012
13+ import com .codedifferently .lesson9 .dataprovider .DataProvider ;
14+ import com .codedifferently .lesson9 .generator .SampleFileGenerator ;
15+
1116@ Configuration
1217@ SpringBootApplication (scanBasePackages = "com.codedifferently" )
1318public class Lesson9 implements CommandLineRunner {
19+ @ Autowired private List <DataProvider > dataProviders ;
1420
1521 public static void main (String [] args ) {
1622 var application = new SpringApplication (Lesson9 .class );
@@ -26,6 +32,22 @@ public void run(String... args) throws Exception {
2632 if (providerName == null ) {
2733 throw new IllegalArgumentException ("Provider name is required" );
2834 }
35+ if (providerName .equals ("-bulk" )){
36+ for (DataProvider provider : dataProviders ) {
37+ String path = getDataPath ();
38+ var fileGenerator = new SampleFileGenerator ();
39+ fileGenerator .createTestFile (path , provider .getProviderName ());
40+ }
41+ return ;
42+ }
43+
44+
45+ // if the providerName is equal to '-bulk'
46+ // go through every dataprovider we have and run this code below using their provider name
47+ // example files for usage - each provider file (to get their name)
48+ // String path = getDataPath();
49+ // var fileGenerator = new SampleFileGenerator();
50+ // fileGenerator.createTestFile(path, providerName);
2951
3052 String path = getDataPath ();
3153 var fileGenerator = new SampleFileGenerator ();
0 commit comments