Skip to content

Commit 98b6c22

Browse files
feat: created a README.md on how to run the bulk, and implemented the Lesson9.java to allow multiple providers to be ran
1 parent a0c35ac commit 98b6c22

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# LESSON 9 - Bulk Sample Generator
2+
3+
Run the app by doing the command:
4+
5+
```js
6+
./gradlew bootRun --args="-bulk"
7+
```

lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/Lesson9.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
package com.codedifferently.lesson9;
22

3-
import com.codedifferently.lesson9.generator.SampleFileGenerator;
43
import java.io.File;
54
import java.nio.file.Paths;
5+
import java.util.List;
6+
7+
import org.springframework.beans.factory.annotation.Autowired;
68
import org.springframework.boot.CommandLineRunner;
79
import org.springframework.boot.SpringApplication;
810
import org.springframework.boot.autoconfigure.SpringBootApplication;
911
import 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")
1318
public 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();

lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/generator/BulkGenerator.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)