Skip to content

Commit bb8bc65

Browse files
committed
feat: implementation complete; not tested
1 parent b9092dc commit bb8bc65

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
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+
67
import org.springframework.boot.CommandLineRunner;
78
import org.springframework.boot.SpringApplication;
89
import org.springframework.boot.autoconfigure.SpringBootApplication;
910
import org.springframework.context.annotation.Configuration;
1011

12+
import com.codedifferently.lesson9.dataprovider.DataProvider;
13+
import com.codedifferently.lesson9.generator.SampleFileGenerator;
14+
1115
@Configuration
1216
@SpringBootApplication(scanBasePackages = "com.codedifferently")
1317
public class Lesson9 implements CommandLineRunner {
14-
18+
private final List<DataProvider> providers;
19+
public Lesson9(List<DataProvider> providers) {
20+
this.providers = providers;
21+
}
1522
public static void main(String[] args) {
1623
var application = new SpringApplication(Lesson9.class);
1724
application.run(args);
@@ -22,23 +29,23 @@ public void run(String... args) throws Exception {
2229
return;
2330
}
2431

25-
var providerName = args[0];
26-
if (providerName == null) {
32+
var option = args[0];
33+
if (option == null) {
2734
throw new IllegalArgumentException("Provider name is required");
2835
}
29-
if (providerName.equals("--all")){
36+
if (option.equals("--all")){
3037
//TODO: change providers to search dynamically for all available providers
31-
String[] providers = {"danielsonadjocy", "johnsonjames", "smithjane", "williamsrobert"};
32-
for (String provider : providers) {
38+
for (DataProvider provider : providers) {
39+
String providerName = provider.getClass().getSimpleName().replace("Provider", "");
3340
String path = getDataPath();
3441
var fileGenerator = new SampleFileGenerator();
35-
//fileGenerator.createProviderFile(path, providerName, provider);
42+
fileGenerator.createProviderFile(path, providerName, provider);
3643
}
3744
return;
3845
}
3946
String path = getDataPath();
4047
var fileGenerator = new SampleFileGenerator();
41-
fileGenerator.createTestFile(path, providerName);
48+
fileGenerator.createTestFile(path, option);
4249
}
4350

4451
private static String getDataPath() {

lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/dataprovider/AnthonyMaysProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.util.Map;
44
import org.springframework.stereotype.Service;
5+
import org.springframework.stereotype.Component;
56

7+
@Component
68
@Service
79
public class AnthonyMaysProvider extends DataProvider {
810
public String getProviderName() {

lesson_09/types/types_app/src/main/java/com/codedifferently/lesson9/dataprovider/DanielsonAdjocyProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.util.Map;
44
import org.springframework.stereotype.Service;
5+
import org.springframework.stereotype.Component;
56

7+
@Component
68
@Service
79
public class DanielsonAdjocyProvider extends DataProvider {
810
public String getProviderName() {

0 commit comments

Comments
 (0)