diff --git a/filters/all.js b/filters/all.js index 55ef4d59a..b92d701e9 100644 --- a/filters/all.js +++ b/filters/all.js @@ -177,3 +177,5 @@ function addBackSlashToPattern(val) { return result; } filter.addBackSlashToPattern = addBackSlashToPattern; + +filter.currentTime = () => (new Date(Date.now())).toISOString(); \ No newline at end of file diff --git a/partials/AmqpConfig.java b/partials/AmqpConfig.java index 1b203fe65..03865566b 100644 --- a/partials/AmqpConfig.java +++ b/partials/AmqpConfig.java @@ -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 { diff --git a/partials/CommonPublisher.java b/partials/CommonPublisher.java index 29df1deec..9fed54fde 100644 --- a/partials/CommonPublisher.java +++ b/partials/CommonPublisher.java @@ -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 { diff --git a/partials/KafkaConfig.java b/partials/KafkaConfig.java index 719f839e8..d5e46676d 100644 --- a/partials/KafkaConfig.java +++ b/partials/KafkaConfig.java @@ -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 { diff --git a/partials/KafkaPublisher.java b/partials/KafkaPublisher.java index 0cff24fc3..96d66458d 100644 --- a/partials/KafkaPublisher.java +++ b/partials/KafkaPublisher.java @@ -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 { diff --git a/partials/MqttConfig.java b/partials/MqttConfig.java index e9581cd5e..61dcc16d9 100644 --- a/partials/MqttConfig.java +++ b/partials/MqttConfig.java @@ -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 { diff --git a/template/src/main/java/com/asyncapi/Application.java b/template/src/main/java/com/asyncapi/Application.java index 513dfe2a7..f9d23a755 100644 --- a/template/src/main/java/com/asyncapi/Application.java +++ b/template/src/main/java/com/asyncapi/Application.java @@ -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 { diff --git a/template/src/main/java/com/asyncapi/model/$$message$$.java b/template/src/main/java/com/asyncapi/model/$$message$$.java index ba72e04d0..b5b1cf05c 100644 --- a/template/src/main/java/com/asyncapi/model/$$message$$.java +++ b/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 %} @@ -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 %} diff --git a/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java b/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java index c5b961c4d..d5d224221 100644 --- a/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java +++ b/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java @@ -12,6 +12,7 @@ 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; @@ -19,6 +20,7 @@ * {{ 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()) %} diff --git a/template/src/main/java/com/asyncapi/service/CommandLinePublisher.java b/template/src/main/java/com/asyncapi/service/CommandLinePublisher.java index 3d5837630..5a8ad0f9e 100644 --- a/template/src/main/java/com/asyncapi/service/CommandLinePublisher.java +++ b/template/src/main/java/com/asyncapi/service/CommandLinePublisher.java @@ -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 { diff --git a/template/src/main/java/com/asyncapi/service/MessageHandlerService.java b/template/src/main/java/com/asyncapi/service/MessageHandlerService.java index 85258282d..ab054224c 100644 --- a/template/src/main/java/com/asyncapi/service/MessageHandlerService.java +++ b/template/src/main/java/com/asyncapi/service/MessageHandlerService.java @@ -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 { diff --git a/template/src/test/java/com/asyncapi/ApplicationTests.java b/template/src/test/java/com/asyncapi/ApplicationTests.java index 4504ab3a0..526b3c2b8 100644 --- a/template/src/test/java/com/asyncapi/ApplicationTests.java +++ b/template/src/test/java/com/asyncapi/ApplicationTests.java @@ -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 { diff --git a/template/src/test/java/com/asyncapi/SimpleKafkaTest.java b/template/src/test/java/com/asyncapi/SimpleKafkaTest.java index 00c4f7331..e5ba389d0 100644 --- a/template/src/test/java/com/asyncapi/SimpleKafkaTest.java +++ b/template/src/test/java/com/asyncapi/SimpleKafkaTest.java @@ -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; @@ -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 { diff --git a/template/src/test/java/com/asyncapi/TestcontainerKafkaTest.java b/template/src/test/java/com/asyncapi/TestcontainerKafkaTest.java index bc6a1b123..d98d47b50 100644 --- a/template/src/test/java/com/asyncapi/TestcontainerKafkaTest.java +++ b/template/src/test/java/com/asyncapi/TestcontainerKafkaTest.java @@ -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.*; @@ -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 { diff --git a/template/src/test/java/com/asyncapi/TestcontainerMqttTest.java b/template/src/test/java/com/asyncapi/TestcontainerMqttTest.java index ae086a610..a60f228c2 100644 --- a/template/src/test/java/com/asyncapi/TestcontainerMqttTest.java +++ b/template/src/test/java/com/asyncapi/TestcontainerMqttTest.java @@ -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; @@ -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 { diff --git a/tests/__snapshots__/additional-formats.test.js.snap b/tests/__snapshots__/additional-formats.test.js.snap index 1215162fa..9b28d637a 100644 --- a/tests/__snapshots__/additional-formats.test.js.snap +++ b/tests/__snapshots__/additional-formats.test.js.snap @@ -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; diff --git a/tests/__snapshots__/kafka.test.js.snap b/tests/__snapshots__/kafka.test.js.snap index 4cbdb4ff7..9abd9f95d 100644 --- a/tests/__snapshots__/kafka.test.js.snap +++ b/tests/__snapshots__/kafka.test.js.snap @@ -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 { @@ -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 { @@ -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 { @@ -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; @@ -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; @@ -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.*; @@ -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 { diff --git a/tests/__snapshots__/mqtt.test.js.snap b/tests/__snapshots__/mqtt.test.js.snap index 64d9c8ed8..228cf14b4 100644 --- a/tests/__snapshots__/mqtt.test.js.snap +++ b/tests/__snapshots__/mqtt.test.js.snap @@ -23,6 +23,9 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHandler; import org.springframework.util.StringUtils; +import javax.annotation.processing.Generated; + +@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate") @Configuration public class Config { @@ -171,6 +174,9 @@ exports[`template integration tests for generated files using the generator and 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="AnyDate") @MessagingGateway public interface PublisherService { @@ -207,6 +213,9 @@ import org.slf4j.LoggerFactory; import org.springframework.messaging.Message; import org.springframework.stereotype.Service; +import javax.annotation.processing.Generated; + +@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate") @Service public class MessageHandlerService { @@ -245,10 +254,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 DimLightPayload { private @Valid Integer percentage; @@ -334,10 +345,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; @@ -423,10 +436,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 TurnOnOffPayload { public enum CommandEnum { @@ -537,12 +552,14 @@ public class TurnOnOffPayload { exports[`template integration tests for generated files using the generator and mqtt example should generate proper config, services and DTOs files for basic example 7`] = ` "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 DimLight { private @Valid DimLightPayload payload; @@ -593,12 +610,14 @@ public class DimLight { exports[`template integration tests for generated files using the generator and mqtt example should generate proper config, services and DTOs files for basic example 8`] = ` "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; @@ -649,12 +668,14 @@ public class LightMeasured { exports[`template integration tests for generated files using the generator and mqtt example should generate proper config, services and DTOs files for basic example 9`] = ` "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 TurnOnOff { private @Valid TurnOnOffPayload payload; @@ -730,6 +751,7 @@ import org.springframework.test.context.DynamicPropertySource; 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; @@ -739,6 +761,7 @@ import static org.junit.Assert.assertEquals; /** * Example of tests for mqtt based on testcontainers library */ +@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate") @RunWith(SpringRunner.class) @SpringBootTest public class TestcontainerMqttTest { @@ -909,6 +932,9 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageHandler; import org.springframework.util.StringUtils; +import javax.annotation.processing.Generated; + +@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate") @Configuration public class Config { @@ -1034,6 +1060,9 @@ exports[`template integration tests for generated files using the generator and 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="AnyDate") @MessagingGateway public interface PublisherService { @@ -1058,6 +1087,9 @@ import org.slf4j.LoggerFactory; import org.springframework.messaging.Message; import org.springframework.stereotype.Service; +import javax.annotation.processing.Generated; + +@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate") @Service public class MessageHandlerService { @@ -1092,10 +1124,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; @@ -1173,12 +1207,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 mqtt 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; @@ -1250,6 +1286,7 @@ import org.springframework.test.context.DynamicPropertySource; 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; @@ -1259,6 +1296,7 @@ import static org.junit.Assert.assertEquals; /** * Example of tests for mqtt based on testcontainers library */ +@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate") @RunWith(SpringRunner.class) @SpringBootTest public class TestcontainerMqttTest { diff --git a/tests/__snapshots__/oneOf.test.js.snap b/tests/__snapshots__/oneOf.test.js.snap index f8738300d..42c7e4f90 100644 --- a/tests/__snapshots__/oneOf.test.js.snap +++ b/tests/__snapshots__/oneOf.test.js.snap @@ -16,6 +16,9 @@ import org.springframework.messaging.handler.annotation.Payload; import com.asyncapi.model.AnonymousSchema1; import com.asyncapi.model.AnonymousSchema7; +import javax.annotation.processing.Generated; + +@Generated(value="com.asyncapi.generator.template.spring", date="AnyDate") @Service public class MessageHandlerService { @@ -70,6 +73,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.*; @@ -82,6 +86,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 { diff --git a/tests/__snapshots__/parameters.test.js.snap b/tests/__snapshots__/parameters.test.js.snap index 1551cd663..2f87b50a1 100644 --- a/tests/__snapshots__/parameters.test.js.snap +++ b/tests/__snapshots__/parameters.test.js.snap @@ -149,6 +149,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 { @@ -180,10 +183,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; @@ -261,12 +266,14 @@ public class LightMeasuredPayload { exports[`integration tests for generated files under different template parameters should generate spring 2 code with parameter 3`] = ` "package com.asyncapi.model; +import javax.annotation.processing.Generated; import javax.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; diff --git a/tests/additional-formats.test.js b/tests/additional-formats.test.js index b995450eb..376a8c1c0 100644 --- a/tests/additional-formats.test.js +++ b/tests/additional-formats.test.js @@ -26,7 +26,8 @@ describe('template integration tests for additional formats of data types', () = ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } }); }); diff --git a/tests/kafka.test.js b/tests/kafka.test.js index 1e88cbb43..05b9d74af 100644 --- a/tests/kafka.test.js +++ b/tests/kafka.test.js @@ -33,7 +33,8 @@ describe('template integration tests for generated files using the generator and ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } }); }); diff --git a/tests/mqtt.test.js b/tests/mqtt.test.js index 6a7eb7370..4f7b58003 100644 --- a/tests/mqtt.test.js +++ b/tests/mqtt.test.js @@ -39,7 +39,8 @@ describe('template integration tests for generated files using the generator and ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } }); @@ -63,7 +64,8 @@ describe('template integration tests for generated files using the generator and ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } }); }); diff --git a/tests/oneOf.test.js b/tests/oneOf.test.js index 31eb3b44f..7ccd0deff 100644 --- a/tests/oneOf.test.js +++ b/tests/oneOf.test.js @@ -27,7 +27,8 @@ describe('template integration tests for generated files using the generator and ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } }); }); diff --git a/tests/parameters.test.js b/tests/parameters.test.js index c15acb6d2..d57ec25f6 100644 --- a/tests/parameters.test.js +++ b/tests/parameters.test.js @@ -31,7 +31,8 @@ describe('integration tests for generated files under different template paramet ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } }); @@ -52,7 +53,8 @@ describe('integration tests for generated files under different template paramet ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } for (const index in notExpectedFiles) { expect(existsSync(path.join(outputDir, notExpectedFiles[index]))).toBeFalsy(); @@ -77,7 +79,8 @@ describe('integration tests for generated files under different template paramet ]; for (const index in expectedFiles) { const file = await readFile(path.join(outputDir, expectedFiles[index]), 'utf8'); - expect(file).toMatchSnapshot(); + const fileWithAnyDate = file.replace(/date="\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)"/, 'date="AnyDate"'); + expect(fileWithAnyDate).toMatchSnapshot(); } for (const index in notExpectedFiles) { expect(existsSync(path.join(outputDir, notExpectedFiles[index]))).toBeFalsy();