-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from ZenWave360/develop
Merging Develop for v1.7.0
- Loading branch information
Showing
68 changed files
with
1,660 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Enforce LF line endings for all text files by default | ||
* text=auto eol=lf | ||
|
||
# Explicit exceptions for CRLF line endings | ||
*.bat text eol=crlf | ||
*.cmd text eol=crlf | ||
*.ps1 text eol=crlf | ||
|
||
# Explicitly mark binary files | ||
# (Git automatically detects these, but this is a safeguard for clarity) | ||
*.pdf binary | ||
*.png binary | ||
*.jpg binary | ||
*.jpeg binary | ||
*.gif binary | ||
*.tif binary | ||
*.tiff binary | ||
*.ico binary | ||
*.svg binary | ||
*.eps binary | ||
*.class binary | ||
*.jar binary | ||
*.war binary | ||
*.7z binary | ||
*.gz binary | ||
*.rar binary | ||
*.tar binary | ||
*.zip binary | ||
*.ttf binary | ||
*.eot binary | ||
*.otf binary | ||
*.woff binary | ||
*.woff2 binary |
105 changes: 105 additions & 0 deletions
105
e2e/src/test/java/io/zenwave360/sdk/e2e/TestPatchAndNaturalIdProject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package io.zenwave360.sdk.e2e; | ||
|
||
import io.zenwave360.sdk.MainGenerator; | ||
import io.zenwave360.sdk.Plugin; | ||
import io.zenwave360.sdk.options.DatabaseType; | ||
import io.zenwave360.sdk.options.PersistenceType; | ||
import io.zenwave360.sdk.options.ProgrammingStyle; | ||
import io.zenwave360.sdk.plugins.BackendApplicationDefaultPlugin; | ||
import io.zenwave360.sdk.plugins.OpenAPIControllersPlugin; | ||
import io.zenwave360.sdk.plugins.ZDLToAsyncAPIPlugin; | ||
import io.zenwave360.sdk.plugins.ZDLToOpenAPIPlugin; | ||
import io.zenwave360.sdk.testutils.MavenCompiler; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.MethodOrderer; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestMethodOrder; | ||
|
||
import java.io.File; | ||
|
||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
public class TestPatchAndNaturalIdProject { | ||
private String basePackage = "io.zenwave360.example"; | ||
|
||
@Test | ||
public void testPatchAndNaturalIdProject() throws Exception { | ||
String sourceFolder = "src/test/resources/projects/patch-and-natural-id/"; | ||
String targetFolder = "target/patch-and-natural-id/"; | ||
String zdlFile = targetFolder + "/patch-and-natural-id.zdl"; | ||
|
||
// copy whole dir from sourceFolder to targetFolder | ||
FileUtils.deleteDirectory(new File(targetFolder)); | ||
FileUtils.forceMkdir(new File(targetFolder)); | ||
FileUtils.copyDirectory(new File(sourceFolder), new File(targetFolder)); | ||
Assertions.assertTrue(new File(targetFolder).exists()); | ||
|
||
Plugin plugin = null; | ||
int exitCode = 0; | ||
|
||
plugin = new ZDLToOpenAPIPlugin() | ||
.withZdlFile(zdlFile) | ||
.withOption("idType", "integer") | ||
.withOption("idTypeFormat", "int64") | ||
.withOption("targetFile", "/src/main/resources/apis/openapi.yml") | ||
.withTargetFolder(targetFolder); | ||
new MainGenerator().generate(plugin); | ||
|
||
plugin = new ZDLToAsyncAPIPlugin() | ||
.withZdlFile(zdlFile) | ||
.withOption("asyncapiVersion", "v3") | ||
.withOption("idType", "integer") | ||
.withOption("idTypeFormat", "int64") | ||
.withOption("targetFile", "/src/main/resources/apis/asyncapi.yml") | ||
.withTargetFolder(targetFolder); | ||
new MainGenerator().generate(plugin); | ||
|
||
plugin = new BackendApplicationDefaultPlugin() | ||
.withZdlFile(zdlFile) | ||
.withTargetFolder(targetFolder) | ||
.withOption("basePackage", basePackage) | ||
.withOption("persistence", PersistenceType.jpa) | ||
.withOption("databaseType", DatabaseType.postgresql) | ||
.withOption("style", ProgrammingStyle.imperative) | ||
.withOption("useLombok", true) | ||
.withOption("includeEmitEventsImplementation", true) | ||
.withOption("forceOverwrite", true) | ||
.withOption("haltOnFailFormatting", false); | ||
|
||
new MainGenerator().generate(plugin); | ||
|
||
TextUtils.replaceInFile(new File(targetFolder + "/src/main/java/io/zenwave360/example/core/implementation/mappers/EventsMapper.java"), | ||
"io.zenwave360.example.core.outbound.events.dtos.Customer asCustomer\\(Customer customer\\);", | ||
""" | ||
@org.mapstruct.Mapping(target = "extraProperties", ignore = true) | ||
io.zenwave360.example.core.outbound.events.dtos.Customer asCustomer(Customer customer); | ||
"""); | ||
|
||
exitCode = MavenCompiler.compile(new File(targetFolder)); | ||
Assertions.assertEquals(0, exitCode); | ||
|
||
plugin = new OpenAPIControllersPlugin() | ||
.withApiFile(targetFolder + "/src/main/resources/apis/openapi.yml") | ||
.withTargetFolder(targetFolder) | ||
.withOption("zdlFile", zdlFile) | ||
.withOption("basePackage", basePackage) | ||
.withOption("controllersPackage", "{{basePackage}}.adapters.web") | ||
.withOption("openApiApiPackage", "{{basePackage}}.adapters.web") | ||
.withOption("openApiModelPackage", "{{basePackage}}.adapters.web.model") | ||
.withOption("openApiModelNameSuffix", "DTO") | ||
.withOption("style", ProgrammingStyle.imperative) | ||
.withOption("haltOnFailFormatting", false); | ||
new MainGenerator().generate(plugin); | ||
|
||
TextUtils.replaceInFile(new File(targetFolder + "/src/main/java/io/zenwave360/example/adapters/web/mappers/CustomerDTOsMapper.java"), | ||
"// request mappings", | ||
""" | ||
// request mappings | ||
default Map map(Object value) { return new HashMap();} | ||
"""); | ||
|
||
exitCode = MavenCompiler.compile(new File(targetFolder)); | ||
Assertions.assertEquals(0, exitCode); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
e2e/src/test/resources/projects/patch-and-natural-id/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: '3.8' | ||
services: | ||
mariadb: | ||
image: mariadb:10.7.1 | ||
# volumes: | ||
# - ~/volumes/mysql/:/var/lib/mysql/ | ||
environment: | ||
- MYSQL_ALLOW_EMPTY_PASSWORD=yes | ||
- MYSQL_DATABASE=zenwave-playground | ||
ports: | ||
- 127.0.0.1:3306:3306 | ||
command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8mb4 --explicit_defaults_for_timestamp | ||
kafka: | ||
image: bashj79/kafka-kraft | ||
ports: | ||
- '9092:9092' |
73 changes: 73 additions & 0 deletions
73
e2e/src/test/resources/projects/patch-and-natural-id/patch-and-natural-id.zdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Sample ZenWave Model Definition. | ||
* Use zenwave-scripts.zdl to generate your code from this model definition. | ||
*/ | ||
config {} | ||
|
||
/** | ||
* Customer entity | ||
*/ | ||
@aggregate | ||
@auditing // adds auditing fields to the entity | ||
entity Customer { | ||
@naturalId | ||
customerId Long required | ||
@naturalId | ||
anotherId String required | ||
|
||
name String required maxlength(254) /** Customer name */ | ||
email String required maxlength(254) | ||
/** Customer Addresses can be stored in a JSON column in the database. */ | ||
@json addresses Address[] minlength(1) maxlength(5) { | ||
street String required maxlength(254) | ||
city String required maxlength(254) | ||
} | ||
} | ||
|
||
@auditing | ||
entity PaymentMethod { | ||
type PaymentMethodType required | ||
cardNumber String required | ||
} | ||
|
||
enum PaymentMethodType { VISA(1), MASTERCARD(2) } | ||
|
||
relationship OneToMany { | ||
@eager | ||
Customer{paymentMethods required maxlength(3)} to PaymentMethod{customer required} | ||
} | ||
|
||
// you can create 'inputs' as dtos for your service methods, or use entities directly | ||
input CustomerSearchCriteria { | ||
name String | ||
email String | ||
city String | ||
state String | ||
} | ||
|
||
@rest("/customers") | ||
service CustomerService for (Customer) { | ||
@post | ||
createCustomer(Customer) Customer withEvents CustomerEvent | ||
|
||
@get("/{customerId}/{anotherId}") @naturalId(Customer) | ||
getCustomer(id) Customer? | ||
@put("/{customerId}/{anotherId}") @naturalId(Customer) | ||
updateCustomer(id, Customer) Customer? withEvents CustomerEvent | ||
@patch("/{customerId}/{anotherId}") @naturalId(Customer) | ||
patchCustomer(id, Customer) Customer? withEvents CustomerEvent | ||
@delete("/{customerId}/{anotherId}") @naturalId(Customer) | ||
deleteCustomer(id) withEvents CustomerEvent | ||
|
||
@get("/search") @paginated | ||
searchCustomers(CustomerSearchCriteria) Customer[] | ||
} | ||
|
||
@copy(Customer) | ||
@asyncapi({ channel: "CustomersChannel", topic: "customers" }) | ||
event CustomerEvent { | ||
id Long | ||
version Integer | ||
// all fields from Customer are copied here, but not relationships | ||
paymentMethods PaymentMethod[] | ||
} |
Oops, something went wrong.