Skip to content

Commit

Permalink
feat: add generated annotation (#323)
Browse files Browse the repository at this point in the history
* add generated annotation

* update tests

* fix date in snapshots
  • Loading branch information
Tenischev committed Oct 2, 2023
1 parent 3221532 commit f8040a0
Show file tree
Hide file tree
Showing 25 changed files with 117 additions and 8 deletions.
2 changes: 2 additions & 0 deletions filters/all.js
Expand Up @@ -177,3 +177,5 @@ function addBackSlashToPattern(val) {
return result;
}
filter.addBackSlashToPattern = addBackSlashToPattern;

filter.currentTime = () => (new Date(Date.now())).toISOString();
3 changes: 3 additions & 0 deletions partials/AmqpConfig.java
Expand Up @@ -18,6 +18,9 @@
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.messaging.MessageChannel;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Configuration
public class Config {

Expand Down
3 changes: 3 additions & 0 deletions partials/CommonPublisher.java
Expand Up @@ -3,6 +3,9 @@
import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.annotation.MessagingGateway;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@MessagingGateway
public interface PublisherService {

Expand Down
2 changes: 2 additions & 0 deletions partials/KafkaConfig.java
Expand Up @@ -75,9 +75,11 @@
import org.springframework.kafka.support.serializer.JsonDeserializer;
import org.springframework.kafka.support.serializer.JsonSerializer;

import javax.annotation.processing.Generated;
import java.util.HashMap;
import java.util.Map;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Configuration
{% if hasPublish %}@EnableKafka{% endif %}
public class Config {
Expand Down
2 changes: 2 additions & 0 deletions partials/KafkaPublisher.java
Expand Up @@ -13,7 +13,9 @@
{%- endfor -%}
{% endif -%}
{% endfor %}
import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Service
public class PublisherService {

Expand Down
3 changes: 3 additions & 0 deletions partials/MqttConfig.java
Expand Up @@ -20,6 +20,9 @@
import org.springframework.messaging.MessageHandler;
import org.springframework.util.StringUtils;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Configuration
public class Config {

Expand Down
3 changes: 3 additions & 0 deletions template/src/main/java/com/asyncapi/Application.java
Expand Up @@ -3,6 +3,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@SpringBootApplication
public class Application {

Expand Down
2 changes: 2 additions & 0 deletions template/src/main/java/com/asyncapi/model/$$message$$.java
@@ -1,5 +1,6 @@
package {{ params['userJavaPackage'] }}.model;

import javax.annotation.processing.Generated;
{% if params.springBoot2 -%}
import javax.validation.Valid;
{% else %}
Expand All @@ -12,6 +13,7 @@
* {{ line | safe}}{% endfor %}{% if message.examples() %}
* Examples: {{message.examples() | examplesToString | safe}}{% endif %}
*/{% endif %}
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
public class {{messageName | camelCase | upperFirst}} {
{%- if message.payload().anyOf() or message.payload().oneOf() %}
{%- set payloadName = 'OneOf' %}{%- set hasPrimitive = false %}
Expand Down
Expand Up @@ -12,13 +12,15 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import javax.annotation.processing.Generated;
import java.util.List;
import java.util.Objects;

{% if schema.description() or schema.examples() %}/**{% for line in schema.description() | splitByLines %}
* {{ line | safe}}{% endfor %}{% if schema.examples() %}
* Examples: {{schema.examples() | examplesToString | safe}}{% endif %}
*/{% endif %}
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
public class {{schemaName | camelCase | upperFirst}} {
{% for propName, prop in schema.properties() %}
{%- set isRequired = propName | isRequired(schema.required()) %}
Expand Down
Expand Up @@ -4,8 +4,10 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.processing.Generated;
import java.util.Random;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Component
public class CommandLinePublisher implements CommandLineRunner {

Expand Down
Expand Up @@ -27,6 +27,9 @@
{%- endif %}
{%- endfor %}
{% endif %}
import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@Service
public class MessageHandlerService {

Expand Down
3 changes: 3 additions & 0 deletions template/src/test/java/com/asyncapi/ApplicationTests.java
Expand Up @@ -5,6 +5,9 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.processing.Generated;

@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApplicationTests {
Expand Down
2 changes: 2 additions & 0 deletions template/src/test/java/com/asyncapi/SimpleKafkaTest.java
Expand Up @@ -41,6 +41,7 @@
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.processing.Generated;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -51,6 +52,7 @@
/**
* Example of tests for kafka based on spring-kafka-test library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class SimpleKafkaTest {
Expand Down
Expand Up @@ -39,6 +39,7 @@
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.shaded.com.google.common.collect.Lists;

import javax.annotation.processing.Generated;
import java.time.Duration;
import java.util.*;

Expand All @@ -51,6 +52,7 @@
/**
* Example of tests for kafka based on testcontainers library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestcontainerKafkaTest {
Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.springframework.test.context.junit4.SpringRunner;
import org.testcontainers.containers.GenericContainer;

import javax.annotation.processing.Generated;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
Expand All @@ -40,6 +41,7 @@
/**
* Example of tests for mqtt based on testcontainers library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="{{''|currentTime }}")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestcontainerMqttTest {
Expand Down
2 changes: 2 additions & 0 deletions tests/__snapshots__/additional-formats.test.js.snap
Expand Up @@ -11,10 +11,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import javax.annotation.processing.Generated;
import java.util.List;
import java.util.Objects;
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
public class SongPayload {
private @Valid java.util.UUID id;
Expand Down
13 changes: 13 additions & 0 deletions tests/__snapshots__/kafka.test.js.snap
Expand Up @@ -20,9 +20,11 @@ import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import org.springframework.kafka.support.serializer.JsonDeserializer;
import org.springframework.kafka.support.serializer.JsonSerializer;
import javax.annotation.processing.Generated;
import java.util.HashMap;
import java.util.Map;
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@Configuration
@EnableKafka
public class Config {
Expand Down Expand Up @@ -104,7 +106,9 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;
import com.asyncapi.model.LightMeasuredPayload;
import javax.annotation.processing.Generated;
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@Service
public class PublisherService {
Expand Down Expand Up @@ -138,6 +142,9 @@ import org.springframework.messaging.handler.annotation.Payload;
import com.asyncapi.model.LightMeasuredPayload;
import javax.annotation.processing.Generated;
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@Service
public class MessageHandlerService {
Expand Down Expand Up @@ -169,10 +176,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import javax.annotation.processing.Generated;
import java.util.List;
import java.util.Objects;
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
public class LightMeasuredPayload {
private @Valid Integer lumens;
Expand Down Expand Up @@ -250,12 +259,14 @@ public class LightMeasuredPayload {
exports[`template integration tests for generated files using the generator and mqtt example should generate proper config, services and DTOs files for provided kafka 5`] = `
"package com.asyncapi.model;
import javax.annotation.processing.Generated;
import jakarta.validation.Valid;
import java.util.Objects;
import java.util.List;
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
public class LightMeasured {
private @Valid LightMeasuredPayload payload;
Expand Down Expand Up @@ -335,6 +346,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.shaded.com.google.common.collect.Lists;
import javax.annotation.processing.Generated;
import java.time.Duration;
import java.util.*;
Expand All @@ -347,6 +359,7 @@ import static org.junit.Assert.assertNotEquals;
/**
* Example of tests for kafka based on testcontainers library
*/
@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestcontainerKafkaTest {
Expand Down

0 comments on commit f8040a0

Please sign in to comment.