Skip to content

Latest commit

 

History

History

spring-boot-mongodb-elasticsearch-kafka-skeleton

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

ZenWave Example

https://github.com/ZenWave360/zenwave-sdk/tree/main/examples/spring-boot-mongo-elasticsearch

ZenWave SDK

Install ZenWave

jbang alias add --fresh --name=zw release@zenwave360/zenwave-sdk

or if you prefer to use the latest snapshot versions:

jbang alias add --fresh --name=zw snapshots@zenwave360/zenwave-sdk

Starting Docker Infrastructure

cd src/main/docker
./start-all-dependencies.sh

Generate Backend Application

jbang zw -p io.zenwave360.sdk.plugins.JDLBackendApplicationDefaultPlugin \
    specFile=src/main/resources/model/orders-model.jdl \
    basePackage=io.zenwave360.example \
    persistence=mongodb \
    style=imperative \
    targetFolder=.

JDL To OpenAPI

Generate OpenAPI definition from JDL entities:

  • Component Schemas for entities, plain and paginated lists
  • CRUD operations for entities
jbang zw -p io.zenwave360.sdk.plugins.JDLToOpenAPIPlugin \
    specFile=src/main/resources/model/orders-model.jdl \
    targetFile=src/main/resources/model/openapi.yml

JDL To AsyncAPI

Generate AsyncAPI definition from JDL entities:

  • One channel for each entity update events
  • Messages and payloads for each entity Create/Update/Delete events (AVRO and AsyncAPI schema)
jbang zw -p io.zenwave360.sdk.plugins.JDLToAsyncAPIPlugin \
    includeCommands=true \
    specFile=src/main/resources/model/orders-model.jdl \
    annotations=aggregate \
    payloadStyle=event \
    targetFile=src/main/resources/model/asyncapi.yml

API-First Maven Plugins

There are two Maven Plugins for API-First code generation:

Use the following command to generate OpenAPI and AsyncAPI api-first code:

mvn clean generate-sources

SpringMVC Controllers from OpenAPI

Generate new SpringMVC controllers from OpenAPI:

jbang zw -p io.zenwave360.sdk.plugins.JDLOpenAPIControllersPlugin \
    specFile=src/main/resources/model/openapi.yml \
    jdlFile=src/main/resources/model/orders-model.jdl \
    basePackage=io.zenwave360.example \
    openApiApiPackage=io.zenwave360.example.adapters.web \
    openApiModelPackage=io.zenwave360.example.adapters.web.model \
    openApiModelNameSuffix=DTO \
    targetFolder=.

Spring WebTestClient

Generates test for SpringMVC or Spring WebFlux using WebTestClient based on OpenAPI specification.

jbang zw -p io.zenwave360.sdk.plugins.SpringWebTestClientPlugin \
    specFile=src/main/resources/model/openapi.yml \
    targetFolder=src/test/java \
    testsPackage=io.zenwave360.example.adapters.web.tests.webtestclient \
    openApiApiPackage=io.zenwave360.example.adapters.web \
    openApiModelPackage=io.zenwave360.example.adapters.web.model \
    openApiModelNameSuffix=DTO \
    groupBy=service

Generate Customer CRUD Integration Test:

jbang zw -p io.zenwave360.sdk.plugins.SpringWebTestClientPlugin \
    specFile=src/main/resources/model/openapi.yml \
    targetFolder=src/test/java \
    testsPackage=io.zenwave360.example.adapters.web \
    openApiApiPackage=io.zenwave360.example.adapters.web \
    openApiModelPackage=io.zenwave360.example.adapters.web.model \
    openApiModelNameSuffix=DTO \
    groupBy=businessFlow \
    businessFlowTestName=Customer_CRUD_IT \
    operationIds=createCustomer,getCustomer,updateCustomer,deleteCustomer

Generate CustomerOrder CRUD Integration Test:

jbang zw -p io.zenwave360.sdk.plugins.SpringWebTestClientPlugin \
    specFile=src/main/resources/model/openapi.yml \
    targetFolder=src/test/java \
    testsPackage=io.zenwave360.example.adapters.web \
    openApiApiPackage=io.zenwave360.example.adapters.web \
    openApiModelPackage=io.zenwave360.example.adapters.web.model \
    openApiModelNameSuffix=DTO \
    groupBy=businessFlow \
    businessFlowTestName=CustomerOrder_CRUD_IT \
    operationIds=createCustomerOrder,getCustomerOrder,updateCustomerOrder,deleteCustomerOrder

AsyncAPI Command Adapters

jbang zw -p io.zenwave360.sdk.plugins.SpringCloudStreams3AdaptersPlugin \
    specFile=src/main/resources/model/asyncapi.yml \
    jdlFile=src/main/resources/model/orders-model.jdl \
    role=provider \
    style=imperative \
    basePackage=io.zenwave360.example \
    modelPackage=io.zenwave360.example.core.domain.events \
    consumerApiPackage=io.zenwave360.example.adapters.commands \
    adaptersPackage=io.zenwave360.example.adapters.commands \
    targetFolder=.

AsyncAPI Commands Tests

jbang zw -p io.zenwave360.sdk.plugins.SpringCloudStreams3TestsPlugin \
    specFile=src/main/resources/model/asyncapi.yml \
    role=provider \
    style=imperative \
    basePackage=io.zenwave360.example \
    consumerApiPackage=io.zenwave360.example.adapters.commands \
    modelPackage=io.zenwave360.example.core.domain.events \
    targetFolder=.

or

mvn zenwave-sdk:generate@consumer-tests

REST-Assured Generator

Generates REST-Assured tests based on OpenAPI specification.

jbang zw -p io.zenwave360.sdk.plugins.RestAssuredPlugin \
    specFile=src/main/resources/model/openapi.yml \
    targetFolder=src/test/java \
    testsPackage=io.zenwave360.example.adapters.web.tests.restassured \
    openApiApiPackage=io.zenwave360.example.adapters.web \
    openApiModelPackage=io.zenwave360.example.adapters.web.model \
    openApiModelNameSuffix=DTO \
    groupBy=service