Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ZenWave360/zenwave-sdk i…
Browse files Browse the repository at this point in the history
…nto develop
  • Loading branch information
ivangsa committed Nov 11, 2024
2 parents c8080b7 + 9b62d51 commit e3f0df6
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ public {{abstractClass entity}} class {{entity.className}} {{addExtends entity}}

{{~#if entity.options.auditing}}
@CreatedBy
@Column(name = "created_by")
@Column(name = "created_by", updatable = false)
protected String createdBy;
@CreatedDate
@Column(name = "created_date", columnDefinition = "TIMESTAMP")
@Column(name = "created_date", columnDefinition = "TIMESTAMP", updatable = false)
protected LocalDateTime createdDate;
@LastModifiedBy
@Column(name = "last_modified_by")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegr
{{entity.instanceName}}.set{{capitalize relationship.fieldName}}({{relationship.fieldName}});
{{~else}}
{{entity.instanceName}}.set{{capitalize relationship.fieldName}}(new HashSet<>());
{{entity.instanceName}}.get{{capitalize relationship.fieldName}}().add({{relationship.fieldName}});
{{entity.instanceName}}.add{{capitalize relationship.fieldName}}({{relationship.fieldName}});
{{~/if}}
{{~/if}}
{{~/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public List<TemplateOutput> generate(Map<String, Object> contextModel) {

handlebarsEngine.getHandlebars().registerHelper("paramsExample", (params, options) -> {
return ((Collection<Map>) params).stream()
.map(p -> p.get("name") + ": " + firstNonNull(p.get("example"), jsonSchemaToJsonFaker.generateExample((Map<String, Object>) p.get("schema"))))
.map(p -> p.get("name") + ": " + firstNonNull(p.get("example"), jsonSchemaToJsonFaker.generateExample((String) p.get("name"), (Map<String, Object>) p.get("schema"))))
.collect(Collectors.joining(", "));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{~/if}}
Given path {{{karatePath operation}}}
{{~#if (queryParams operation)}}
And def queryParams = {{{paramsExample (queryParams operation)}}}
And def queryParams = { {{{paramsExample (queryParams operation)}}} }
{{~/if}}
{{~#if operation.x--request-dto}}
And request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum RequestPayloadType {
public String baseTestClassPackage = "{{testsPackage}}";

@DocumentedOption(description = "Class name suffix for generated test classes")
public String testSuffix = "IT";
public String testSuffix = "IntegrationTest";

@DocumentedOption(description = "Business Flow Test name")
public String businessFlowTestName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public void test_output_business_flow(String openapi, String operationIds, Strin

@ParameterizedTest(name = "[{index}] {displayName} {0}")
@CsvSource({
"openapi-petstore.yml, addPet, 'PetApiIT'",
"openapi-orders.yml, createCustomer, 'CustomerApiIT'"
"openapi-petstore.yml, addPet, 'PetApiIntegrationTest'",
"openapi-orders.yml, createCustomer, 'CustomerApiIntegrationTest'"
})
public void test_output_by_one_service(String openapi, String operationId, String controllers) throws Exception {
String targetFolder = "target/test_output_by_one_service_" + openapi.replaceAll("\\.", "_");
Expand Down Expand Up @@ -123,8 +123,8 @@ public void test_output_by_one_service(String openapi, String operationId, Strin

@ParameterizedTest(name = "[{index}] {displayName} {0}")
@CsvSource({
"openapi-petstore.yml, addPet, 'PetApiIT'",
"openapi-orders.yml, createCustomer, 'CustomerApiIT'"
"openapi-petstore.yml, addPet, 'PetApiIntegrationTest'",
"openapi-orders.yml, createCustomer, 'CustomerApiIntegrationTest'"
})
public void test_output_by_one_service_simple_domain_packaging(String openapi, String operationId, String controllers) throws Exception {
String targetFolder = "target/test_output_by_one_service_simple_domain_packaging_" + openapi.replaceAll("\\.", "_");
Expand Down Expand Up @@ -153,8 +153,8 @@ public void test_output_by_one_service_simple_domain_packaging(String openapi, S

@ParameterizedTest(name = "[{index}] {displayName} {0}")
@CsvSource({
"openapi-petstore.yml, 'PetApiIT'",
"openapi-orders.yml, 'CustomerApiIT'"
"openapi-petstore.yml, 'PetApiIntegrationTest'",
"openapi-orders.yml, 'CustomerApiIntegrationTest'"
})
public void test_output_by_service(String openapi, String controllers) throws Exception {
String targetFolder = "target/test_output_by_service_" + openapi.replaceAll("\\.", "_");
Expand All @@ -181,8 +181,8 @@ public void test_output_by_service(String openapi, String controllers) throws Ex

@ParameterizedTest(name = "[{index}] {displayName} {0}")
@CsvSource({
"openapi-petstore.yml, 'PetApi/AddPetIT'",
"openapi-orders.yml, 'CustomerOrderApi/CreateCustomerOrderIT'"
"openapi-petstore.yml, 'PetApi/AddPetIntegrationTest'",
"openapi-orders.yml, 'CustomerOrderApi/CreateCustomerOrderIntegrationTest'"
})
public void test_output_by_operation(String openapi, String controllers) throws Exception {
String targetFolder = "target/test_output_by_operation_" + openapi.replaceAll("\\.", "_");
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<reflections.version>0.10.2</reflections.version>
<handlebars-java.version>4.3.1</handlebars-java.version>
<json-path.version>2.9.0</json-path.version>
<json-schema-ref-parser-jvm.version>0.8.6</json-schema-ref-parser-jvm.version>
<zdl-jvm.version>1.2.1</zdl-jvm.version>
<json-schema-ref-parser-jvm.version>0.8.7</json-schema-ref-parser-jvm.version>
<zdl-jvm.version>1.2.2</zdl-jvm.version>
<graphql-java.version>19.2</graphql-java.version>
<google-java-format.version>1.7</google-java-format.version>
<palantir-java-format.version>2.38.0</palantir-java-format.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ public Object generateExample(Map<String, Object> schema) {
return generateObject(null, schema);
}

/**
* Returns either a Map or a List of Maps that represents a JSON object.
*
* @param schema
* @return
*/
public Object generateExample(String propertyName, Map<String, Object> schema) {
return generateObject(propertyName, schema);
}

public String generateExampleAsJson(Map<String, Object> schema) {
var jsonExample = generateExample(schema);
try {
Expand Down Expand Up @@ -96,6 +106,11 @@ protected String generateString(String propertyName, Map<String, Object> schemaN
int index = random.nextInt(enums.size());
return enums.get(index);
}

if ("sort".equals(propertyName)) {
return "id:asc";
}

Integer min = asInteger(schemaNode.get("min-length"));
Integer max = asInteger(schemaNode.get("max-length"));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
package io.zenwave360.sdk.options;

import com.fasterxml.jackson.annotation.JsonCreator;

public enum DatabaseType {
generic,
postgresql,
mysql,
mariadb,
oracle;

@JsonCreator
public static DatabaseType fromValue(String value) {
for (DatabaseType type : DatabaseType.values()) {
if (type.name().equalsIgnoreCase(value)) {
return type;
}
}
return generic;
}
}

0 comments on commit e3f0df6

Please sign in to comment.