Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/change secrets impl #45

Merged
merged 10 commits into from
Apr 28, 2020
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ gradle gda --value [referenceNumberDrivenAdapter]
| ------------------ | ------------ |
| 1|JPA Repository |
| 2|Mongo Repository |
| 3|Secrets Manager Consumer |
| 4|Async Event Bus |
| 3|Async Event Bus |

5 The ```generateEntryPoint | gep``` task will generate a class in Infrastructure layer, this task have one required parameter ```value```.
```sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,42 @@ public void canRunTaskGenerateEntryPointCaseWithParameters() {

@Test
public void canRunTaskGenerateDrivenAdapterWithParameters() {
canRunTaskGenerateStructureWithOutParameters();
String task = "generateDrivenAdapter";
String valueDrivenAdapter = "1";

runner.withArguments(task, "--value=" + valueDrivenAdapter);
runner.withProjectDir(projectDir);
BuildResult result = runner.build();

assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository/build.gradle").exists());
assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository/src/main/java/co/com/bancolombia/jpa/JPARepository.java").exists());
assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository/src/main/java/co/com/bancolombia/jpa/JPARepositoryAdapter.java").exists());

assertTrue(new File("build/functionalTest/infrastructure//helpers/jpa-repository-commons/build.gradle").exists());
assertTrue(new File("build/functionalTest/infrastructure/helpers/jpa-repository-commons/src/main/java/co/com/bancolombia/jpa/AdapterOperations.java").exists());


assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/bancolombia/config/jpa/JpaConfig.java").exists());
assertTrue(new File("build/functionalTest/applications/app-service/src/main/resources/application-jpaAdapter.yaml").exists());
assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/bancolombia/model/secret/Secret.java").exists());

assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS);
}

@Test
public void canRunTaskGenerateDrivenAdapterEventBusTest() {
canRunTaskGenerateStructureWithOutParameters();
String task = "generateDrivenAdapter";
String valueDrivenAdapter = "3";

runner.withArguments(task, "--value=" + valueDrivenAdapter);
runner.withProjectDir(projectDir);
BuildResult result = runner.build();
assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/secrets-manager-consumer/build.gradle").exists());
assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/secrets-manager-consumer/src/main/java/co/com/bancolombia/secrets/SecretsManager.java").exists());

assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/async-event-bus/build.gradle").exists());
assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/async-event-bus/src/main/java/co/com/bancolombia/events/ReactiveEventsGateway.java").exists());
assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/bancolombia/model/event/gateways/EventRepository.java").exists());

assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/co/com/bancolombia/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class Utils {
private Utils() {
}

public static void writeString(Project project, String nameFile, String data) throws IOException {
project.getLogger().debug(project.file(nameFile).getAbsolutePath());
public static void writeString(Project project, String filePath, String data) throws IOException {
project.getLogger().debug(project.file(filePath).getAbsolutePath());
File file = project
.file(validatePath(nameFile))
.file(validatePath(filePath))
.getAbsoluteFile();

try (FileWriter fileWriter = new FileWriter(file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import co.com.bancolombia.models.drivenadapters.AsyncEventBusDrivenAdapter;
import co.com.bancolombia.models.drivenadapters.JPADrivenAdapter;
import co.com.bancolombia.models.drivenadapters.MongoDrivenAdapter;
import co.com.bancolombia.models.drivenadapters.SecretManagerDrivenAdapter;
import co.com.bancolombia.templates.DrivenAdapterTemplate;

import java.io.IOException;
Expand All @@ -25,9 +24,6 @@ public AbstractModule makeDrivenAdapter(int codeDrivenAdapter) throws IOExceptio
case MONGO_REPOSITORY:
drivenAdapter = new MongoDrivenAdapter();
break;
case SECRETS_MANAGER_CONSUMER:
drivenAdapter = new SecretManagerDrivenAdapter();
break;
case ASYNC_EVENT_BUS:
drivenAdapter = new AsyncEventBusDrivenAdapter();
break;
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/co/com/bancolombia/models/AbstractModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public abstract class AbstractModule {
private String helperDir;
private String modelName;
private String modelDir;
private String configFileName;
private String propertiesFileName;
private String gatewayDir;
private String gatewayName;

public AbstractModule() throws IOException {
setPackageName(Utils.readProperties("package").replaceAll("\\.", "\\/"));
Expand Down Expand Up @@ -64,6 +68,18 @@ public boolean hasHelperModule() {
return nameHelper != null;
}

public boolean hasConfigFile() {
return configFileName != null;
}

public boolean hasPropertiesFile() {
return configFileName != null;
}

public boolean hasGateway() {
return gatewayName != null;
}

public String getModuleDirSrc() {
return moduleDir.concat("/").concat(Constants.MAIN_JAVA).concat("/").concat(packageName)
.concat("/").concat(modulePackage);
Expand All @@ -73,4 +89,9 @@ public String getModuleDirTest() {
return moduleDir.concat("/").concat(Constants.TEST_JAVA).concat("/").concat(packageName)
.concat("/").concat(modulePackage);
}

public abstract String getAppServiceImports();

public abstract String getPropertiesFileContent();

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ public AsyncEventBusDrivenAdapter() throws IOException {
super.setName("async-event-bus");
super.setModulePackage("events");
super.setModelName(DrivenAdapterTemplate.EVENT_BUS_GATEWAY_CLASS);
super.setModelDir(Constants.DOMAIN.concat("/")
.concat(Constants.MODEL).concat("/").concat(Constants.MAIN_JAVA)
.concat("/").concat(super.getPackageName()));
super.setGatewayName("Event");
super.setGatewayDir(Constants.DOMAIN.concat("/")
.concat(Constants.MODEL).concat("/")
.concat(Constants.MAIN_JAVA).concat("/")
.concat(super.getPackageName()).concat("/")
.concat(Constants.MODEL).concat("/")
.concat(DrivenAdapterTemplate.EVENT_BUS_MODEL_NAME).concat("/")
.concat(Constants.GATEWAYS));
super.setModuleDir(Constants.INFRASTRUCTURE
.concat("/").concat(Constants.DRIVEN_ADAPTERS)
.concat("/").concat(super.getName()));
Expand Down Expand Up @@ -53,4 +58,14 @@ public String getInterfaceModule() {
.concat(".").concat(DrivenAdapterTemplate.COMMON)
.concat(".").concat(Constants.GATEWAYS));
}

@Override
public String getAppServiceImports() {
return "";
}

@Override
public String getPropertiesFileContent() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import co.com.bancolombia.templates.Constants;
import co.com.bancolombia.templates.DrivenAdapterTemplate;
import co.com.bancolombia.templates.HelperTemplate;
import co.com.bancolombia.templates.properties.PropertiesTemplate;

import java.io.IOException;

Expand All @@ -15,6 +16,15 @@ public JPADrivenAdapter() throws IOException {
super.setNameHelper("jpa-repository-commons");
super.setModulePackage("jpa");
super.setHelperPackage("jpa");
super.setConfigFileName("JpaConfig");
super.setPropertiesFileName("jpaAdapter");
super.setModelName("Secret");
super.setModelDir(Constants.DOMAIN.concat("/")
.concat(Constants.MODEL).concat("/")
.concat(Constants.MAIN_JAVA).concat("/")
.concat(super.getPackageName()).concat("/")
.concat(Constants.MODEL).concat("/")
.concat(DrivenAdapterTemplate.SECRET_MODEL_NAME));
super.setModuleDir(Constants.INFRASTRUCTURE
.concat("/").concat(Constants.DRIVEN_ADAPTERS)
.concat("/").concat(super.getName()));
Expand Down Expand Up @@ -61,6 +71,16 @@ public String getHelperModuleClassContent() {
.concat(".").concat(super.getHelperPackage()));
}

@Override
public String getAppServiceImports() {
return "dependencies { \n".concat(DrivenAdapterTemplate.getJPAImportContent());
}

@Override
public String getPropertiesFileContent() {
return PropertiesTemplate.getJpaPropertiesContent();
}

@Override
public String getBuildGradleContentModule() {
return DrivenAdapterTemplate.getBuildGradleJPARepository();
Expand All @@ -72,5 +92,4 @@ public String getSettingsGradleModule() {
.getSettingsJPARepositoryContent()
.concat(HelperTemplate.getSettingsHelperJPAContent());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public String getHelperModuleClassContent() {
.concat(".").concat(super.getHelperPackage()));
}

@Override
public String getAppServiceImports() {
return "";
}

@Override
public String getPropertiesFileContent() {
return null;
}

@Override
public String getBuildGradleContentModule() {
return DrivenAdapterTemplate.getBuildGradleMongoRepository();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public String getModuleClassContent() {
.concat(".").concat(super.getModulePackage()));
}

@Override
public String getAppServiceImports() {
return "";
}

@Override
public String getPropertiesFileContent() {
return null;
}

@Override
public String getBuildGradleContentModule() {
return EntryPointTemplate.getBuildGradleReactiveWeb();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/co/com/bancolombia/models/entrypoints/ApiRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public String getModuleClassContent() {
.concat(".").concat(super.getModulePackage()));
}

@Override
public String getAppServiceImports() {
return "";
}

@Override
public String getPropertiesFileContent() {
return null;
}

@Override
public String getBuildGradleContentModule() {
return EntryPointTemplate.getBuildGradleApiRest();
Expand Down
Loading