From c41dc786f8f37e3863365d71b0388cb35958651d Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Sun, 9 Apr 2023 09:49:45 +0200 Subject: [PATCH 1/9] Enable snapshot-testing in base class --- .../com/origin/snapshots/ReflectionUtils.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java new file mode 100644 index 0000000..a0bbdb8 --- /dev/null +++ b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java @@ -0,0 +1,48 @@ +package au.com.origin.snapshots; + +import lombok.experimental.UtilityClass; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Optional; +import java.util.function.Predicate; + +@UtilityClass +public class ReflectionUtils { + + /** + * Find {@link Field} by given predicate. + *

+ * Invoke the given predicate on all fields in the target class, going up the class hierarchy to get all declared fields. + * + * @param clazz the target class to analyze + * @param predicate the predicate + * @return the field or empty optional + */ + public static Optional findFieldByPredicate(final Class clazz, final Predicate predicate) { + Class targetClass = clazz; + + do { + final Field[] fields = targetClass.getDeclaredFields(); + for (final Field field : fields) { + if (!predicate.test(field)) { + continue; + } + return Optional.of(field); + } + targetClass = targetClass.getSuperclass(); + } + while (targetClass != null && targetClass != Object.class); + + return Optional.empty(); + } + + public static void makeAccessible(final Field field) { + if ((!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || + Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) { + field.setAccessible(true); + } + } + +} From c5ba693d10055f6610a1950316e8396856fe891c Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Wed, 19 Apr 2023 06:55:53 +0200 Subject: [PATCH 2/9] Format code using spotless --- .../com/origin/snapshots/ReflectionUtils.java | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java index a0bbdb8..0f447d7 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java +++ b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java @@ -1,48 +1,48 @@ package au.com.origin.snapshots; -import lombok.experimental.UtilityClass; - import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Optional; import java.util.function.Predicate; +import lombok.experimental.UtilityClass; @UtilityClass public class ReflectionUtils { - /** - * Find {@link Field} by given predicate. - *

- * Invoke the given predicate on all fields in the target class, going up the class hierarchy to get all declared fields. - * - * @param clazz the target class to analyze - * @param predicate the predicate - * @return the field or empty optional - */ - public static Optional findFieldByPredicate(final Class clazz, final Predicate predicate) { - Class targetClass = clazz; - - do { - final Field[] fields = targetClass.getDeclaredFields(); - for (final Field field : fields) { - if (!predicate.test(field)) { - continue; - } - return Optional.of(field); - } - targetClass = targetClass.getSuperclass(); + /** + * Find {@link Field} by given predicate. + * + *

Invoke the given predicate on all fields in the target class, going up the class hierarchy + * to get all declared fields. + * + * @param clazz the target class to analyze + * @param predicate the predicate + * @return the field or empty optional + */ + public static Optional findFieldByPredicate( + final Class clazz, final Predicate predicate) { + Class targetClass = clazz; + + do { + final Field[] fields = targetClass.getDeclaredFields(); + for (final Field field : fields) { + if (!predicate.test(field)) { + continue; } - while (targetClass != null && targetClass != Object.class); - - return Optional.empty(); + return Optional.of(field); + } + targetClass = targetClass.getSuperclass(); + } while (targetClass != null && targetClass != Object.class); + + return Optional.empty(); + } + + public static void makeAccessible(final Field field) { + if ((!Modifier.isPublic(field.getModifiers()) + || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) + || Modifier.isFinal(field.getModifiers())) + && !field.isAccessible()) { + field.setAccessible(true); } - - public static void makeAccessible(final Field field) { - if ((!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || - Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) { - field.setAccessible(true); - } - } - + } } From 548ac8b8c470e10c293ddc60fdbf38fc4cd13250 Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Sat, 22 Apr 2023 09:11:13 +0200 Subject: [PATCH 3/9] Move ReflectionUtils to a separate package --- .../com/origin/snapshots/ReflectionUtils.java | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java deleted file mode 100644 index 0f447d7..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/ReflectionUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -package au.com.origin.snapshots; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Optional; -import java.util.function.Predicate; -import lombok.experimental.UtilityClass; - -@UtilityClass -public class ReflectionUtils { - - /** - * Find {@link Field} by given predicate. - * - *

Invoke the given predicate on all fields in the target class, going up the class hierarchy - * to get all declared fields. - * - * @param clazz the target class to analyze - * @param predicate the predicate - * @return the field or empty optional - */ - public static Optional findFieldByPredicate( - final Class clazz, final Predicate predicate) { - Class targetClass = clazz; - - do { - final Field[] fields = targetClass.getDeclaredFields(); - for (final Field field : fields) { - if (!predicate.test(field)) { - continue; - } - return Optional.of(field); - } - targetClass = targetClass.getSuperclass(); - } while (targetClass != null && targetClass != Object.class); - - return Optional.empty(); - } - - public static void makeAccessible(final Field field) { - if ((!Modifier.isPublic(field.getModifiers()) - || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) - || Modifier.isFinal(field.getModifiers())) - && !field.isAccessible()) { - field.setAccessible(true); - } - } -} From e46653b35921d2a0506617b366615b4107b79330 Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Fri, 23 Jan 2026 07:50:36 +0100 Subject: [PATCH 4/9] feat: add initial support for jackson3 --- README.md | 24 +-- gradle/publishing.gradle | 127 ++++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- java-snapshot-testing-core/build.gradle | 5 +- java-snapshot-testing-junit4/build.gradle | 4 +- java-snapshot-testing-junit5/build.gradle | 4 +- ...assTest$NestedClassWithExpectInstance.snap | 3 - .../build.gradle | 12 +- .../build.gradle | 53 ++++++ .../v1/DeterministicCollectionModule.java | 64 ++++++++ ...eterministicJacksonSnapshotSerializer.java | 24 +++ .../v1/JacksonSnapshotSerializer.java | 100 +++++++++++ .../snapshots/jackson3/NoNameChangeTest.java | 24 +++ .../jackson3/ReflectionUtilities.java | 30 ++++ .../snapshots/jackson3/docs/BaseEntity.java | 15 ++ .../jackson3/docs/CustomSerializerTest.java | 25 +++ .../docs/HibernateSnapshotSerializer.java | 40 +++++ .../jackson3/docs/JsonAssertReporter.java | 21 +++ .../jackson3/docs/JsonObjectComparator.java | 19 +++ .../__snapshots__/CustomSerializerTest.snap | 5 + ...ministicJacksonSnapshotSerializerTest.java | 141 ++++++++++++++++ .../v1/JacksonSnapshotSerializerTest.java | 155 ++++++++++++++++++ ...ministicJacksonSnapshotSerializerTest.snap | 140 ++++++++++++++++ .../JacksonSnapshotSerializerTest.snap | 140 ++++++++++++++++ .../src/test/resources/snapshot.properties | 8 + java-snapshot-testing-spock/build.gradle | 16 +- .../origin/snapshots/SpecificationBase.groovy | 7 +- settings.gradle | 2 +- 28 files changed, 1121 insertions(+), 89 deletions(-) delete mode 100644 java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap create mode 100644 java-snapshot-testing-plugin-jackson3/build.gradle create mode 100644 java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap create mode 100644 java-snapshot-testing-plugin-jackson3/src/test/resources/snapshot.properties diff --git a/README.md b/README.md index 04c057f..28a4e54 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,12 @@ testImplementation("org.slf4j:slf4j-simple:2.0.0-alpha0") // Optional: Many will want to serialize into JSON. In this case you should also add the Jackson plugin testImplementation 'io.github.origin-energy:java-snapshot-testing-plugin-jackson:4.+' -testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3' -testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3' +testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' +testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' // Optional: If you want Jackson to serialize Java 8 date/time types or Optionals you should also add the following dependencies -testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.3' -testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.3' +testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.20.1' +testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1' ``` 2. Create `snapshot.properties` and configure your global settings. Be sure to set `output-dir` appropriately for your @@ -49,8 +49,8 @@ testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.3' ```text serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer serializer.base64=au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer -serializer.json=au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer -serializer.orderedJson=au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer +serializer.json=au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer +serializer.orderedJson=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter snapshot-dir=__snapshots__ @@ -154,11 +154,11 @@ Plugins - You need jackson on your classpath (Gradle example) ```groovy // Required java-snapshot-testing peer dependencies - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3' + testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' + testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' // Optional java-snapshot-testing peer dependencies - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.3' - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.3' + testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.20.1' + testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1' ``` ## How does it work? @@ -466,8 +466,8 @@ For example: ```text serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer serializer.base64=au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer -serializer.json=au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer -serializer.orderedJson=au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer +serializer.json=au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer +serializer.orderedJson=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter snapshot-dir=__snapshots__ diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 5fd7c68..5f690cd 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -1,88 +1,119 @@ -task javadocJar(type: Jar) { +import org.gradle.api.publish.maven.MavenPublication +import groovy.xml.XmlUtil + +tasks.register('javadocJar', Jar) { archiveClassifier.set('javadoc') - from javadoc + from tasks.named('javadoc') } -task sourcesJar(type: Jar) { +tasks.register('sourcesJar', Jar) { archiveClassifier.set('sources') from sourceSets.main.allSource } -artifacts { - archives javadocJar, sourcesJar -} - apply plugin: 'net.researchgate.release' -// Sign for maven central deployment -if (project.hasProperty("sign")) { - apply plugin: 'signing' - signing { - def signingKey = findProperty("signingKey") - def signingPassword = findProperty("signingPassword") - useInMemoryPgpKeys(signingKey, signingPassword) - sign configurations.archives - } - - // previously the plugin was using the `build` version which did not include the shadowed dependencies - signArchives.dependsOn 'shadowJar' -} - -// Maven Central Publishing +// Maven Central Publishing (Gradle 7/8+) if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) { - apply plugin: 'maven' + apply plugin: 'maven-publish' + // If you're using the nexus-staging plugin elsewhere, keep this block. + // (This config is unrelated to Gradle's 'maven' plugin and is still fine.) nexusStaging { username project.property("ossrhUsername") password project.property("ossrhPassword") packageGroup 'io.github.origin-energy' } - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + // Ensure the shaded jar is what gets published as the main artifact. + // ShadowJar defaults to classifier "all". If you want the published jar to be the default artifact + // (no classifier), uncomment the next block. + // + // tasks.named('shadowJar') { + // archiveClassifier.set('') + // } - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } + publishing { + publications { + mavenJava(MavenPublication) { + // Publish the shaded jar instead of the plain jar + artifact(tasks.named('shadowJar')) - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } + // Attach sources + javadoc + artifact(tasks.named('sourcesJar')) + artifact(tasks.named('javadocJar')) + + pom { + name = 'java-snapsho-testing' + packaging = 'jar' + description = 'Snapshot Testing for Java' + url = 'https://github.com/origin-energy/java-snapshot-testing' - pom.project { - name 'java-snapsho-testing' - packaging 'jar' - description 'Snapshot Testing for Java' - url 'https://github.com/origin-energy/java-snapshot-testing' scm { - connection 'scm:git:https://github.com/origin-energy/java-snapshot-testing' - url 'https://github.com/origin-energy/java-snapshot-testing' + connection = 'scm:git:https://github.com/origin-energy/java-snapshot-testing' + url = 'https://github.com/origin-energy/java-snapshot-testing' } licenses { license { - name 'MIT License' - url 'http://www.opensource.org/licenses/mit-license.php' + name = 'MIT License' + url = 'http://www.opensource.org/licenses/mit-license.php' } } developers { developer { - id 'jack.matthews' - name 'Jack Matthews' - email 'jack.matthews@origin.com.au' + id = 'jack.matthews' + name = 'Jack Matthews' + email = 'jack.matthews@origin.com.au' + } + } + + // We clear out all the dependencies because we have shadowed them inside the jar + withXml { + def root = asNode() + def deps = root.dependencies + if (deps) { + root.remove(deps) } } } + } + } + + repositories { + maven { + def releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + def snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/") + url = version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl - // We clear out all the dependencies because we have shadowed them inside the jar - pom.whenConfigured { - p -> p.dependencies = [] + credentials { + username = project.property("ossrhUsername").toString() + password = project.property("ossrhPassword").toString() } } } } } +// Sign for Maven Central deployment (Gradle 7/8+) +if (project.hasProperty("sign")) { + apply plugin: 'signing' + + signing { + def signingKey = findProperty("signingKey") + def signingPassword = findProperty("signingPassword") + useInMemoryPgpKeys(signingKey, signingPassword) + + // Sign the publication (modern replacement for signing.signPom(deployment)) + // Only works if maven-publish is applied (i.e., ossrh creds are present) + if (plugins.hasPlugin('maven-publish')) { + sign publishing.publications.mavenJava + } + } + + // Keep the same intent: ensure shaded jar exists before publish/sign + tasks.matching { it.name.startsWith("publish") }.configureEach { + dependsOn tasks.named('shadowJar') + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d355f4c..070cb70 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java-snapshot-testing-core/build.gradle b/java-snapshot-testing-core/build.gradle index 7b4e6c3..85b6954 100644 --- a/java-snapshot-testing-core/build.gradle +++ b/java-snapshot-testing-core/build.gradle @@ -2,9 +2,8 @@ apply from: "../gradle/publishing.gradle" apply from: "../gradle/spotless.gradle" dependencies { - - compileOnly 'com.fasterxml.jackson.core:jackson-core:2.11.3' - compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.11.3' + compileOnly 'com.fasterxml.jackson.core:jackson-core:2.20.1' + compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.20.1' implementation 'org.assertj:assertj-core:3.11.1' implementation 'org.opentest4j:opentest4j:1.2.0' diff --git a/java-snapshot-testing-junit4/build.gradle b/java-snapshot-testing-junit4/build.gradle index 54745cb..1545eb2 100644 --- a/java-snapshot-testing-junit4/build.gradle +++ b/java-snapshot-testing-junit4/build.gradle @@ -15,8 +15,8 @@ dependencies { testImplementation 'org.assertj:assertj-core:3.11.1' // Required java-snapshot-testing peer dependencies - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3' + testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' + testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' } publishing { diff --git a/java-snapshot-testing-junit5/build.gradle b/java-snapshot-testing-junit5/build.gradle index 0b09446..b9d3251 100644 --- a/java-snapshot-testing-junit5/build.gradle +++ b/java-snapshot-testing-junit5/build.gradle @@ -21,8 +21,8 @@ dependencies { // Required java-snapshot-testing peer dependencies testImplementation project(':java-snapshot-testing-plugin-jackson') - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3' + testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' + testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' } test { useJUnitPlatform() } diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap b/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap deleted file mode 100644 index 7fd7503..0000000 --- a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTest$NestedClassWithExpectInstance.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson/build.gradle b/java-snapshot-testing-plugin-jackson/build.gradle index c2660d3..0069ba1 100644 --- a/java-snapshot-testing-plugin-jackson/build.gradle +++ b/java-snapshot-testing-plugin-jackson/build.gradle @@ -5,8 +5,8 @@ dependencies { compileOnly project(':java-snapshot-testing-core') // Client needs to supply their own versions - compileOnly 'com.fasterxml.jackson.core:jackson-core:2.11.3' - compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.11.3' + compileOnly 'com.fasterxml.jackson.core:jackson-core:2.20.1' + compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.20.1' // User supplied Junit5 version compileOnly 'org.junit.jupiter:junit-jupiter-api:5.3.2' @@ -21,10 +21,10 @@ dependencies { testImplementation 'org.assertj:assertj-core:3.11.1' testImplementation 'org.skyscreamer:jsonassert:1.5.0' // For docs/ reporter example - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.16.0' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0' - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.16.0' - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.0' + testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' + testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' + testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.20.1' + testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1' } test { useJUnitPlatform() } diff --git a/java-snapshot-testing-plugin-jackson3/build.gradle b/java-snapshot-testing-plugin-jackson3/build.gradle new file mode 100644 index 0000000..4ebe348 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/build.gradle @@ -0,0 +1,53 @@ +apply from: "../gradle/publishing.gradle" +apply from: "../gradle/spotless.gradle" + +sourceCompatibility = '17' +targetCompatibility = '17' + +java { + toolchain { languageVersion = JavaLanguageVersion.of(17) } +} + +tasks.withType(JavaCompile).configureEach { + options.release = 17 +} + + +dependencies { + compileOnly project(':java-snapshot-testing-core') + + // Client needs to supply their own versions + compileOnly 'tools.jackson.core:jackson-core:3.0.3' + compileOnly 'tools.jackson.core:jackson-databind:3.0.3' + + // User supplied Junit5 version + compileOnly 'org.junit.jupiter:junit-jupiter-api:5.3.2' + compileOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2' + + // Testing + testImplementation project(':java-snapshot-testing-core') + testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.3.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.3.2' + testImplementation 'org.assertj:assertj-core:3.11.1' + testImplementation 'org.skyscreamer:jsonassert:1.5.0' // For docs/ reporter example + + testImplementation 'tools.jackson.core:jackson-core:3.0.3' + testImplementation 'tools.jackson.core:jackson-databind:3.0.3' + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.3.2' +} + +test { useJUnitPlatform() } + +publishing { + publications { + myPublication(MavenPublication) { + artifact shadowJar + groupId 'io.github.origin-energy' + artifactId 'java-snapshot-testing-plugin-jackson' + } + } +} \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java b/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java new file mode 100644 index 0000000..e5f348a --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java @@ -0,0 +1,64 @@ +package au.com.origin.snapshots.jackson3.serializers.v1; + +import lombok.extern.slf4j.Slf4j; +import tools.jackson.core.JacksonException; +import tools.jackson.core.JsonGenerator; +import tools.jackson.databind.SerializationContext; +import tools.jackson.databind.ValueSerializer; +import tools.jackson.databind.module.SimpleModule; + +import java.util.Collection; +import java.util.Collections; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Inspired by: + * https://www.stubbornjava.com/posts/creating-a-somewhat-deterministic-jackson-objectmapper + */ +@Slf4j +public class DeterministicCollectionModule extends SimpleModule { + + public DeterministicCollectionModule() { + addSerializer(Collection.class, new CollectionSerializer()); + } + + /** + * Collections gets converted into a sorted Object[]. This then gets serialized using the default + * Array serializer. + */ + private static class CollectionSerializer extends ValueSerializer> { + + @Override + public void serialize(Collection value, JsonGenerator gen, SerializationContext ctxt) + throws JacksonException { + Object[] sorted = convert(value); + + if (value == null) { + ctxt.getDefaultNullValueSerializer().serialize(null, gen, ctxt); + } else { + ctxt.findTypedValueSerializer(Object[].class, true).serialize(sorted, gen, ctxt); + } + } + + private Object[] convert(Collection value) { + if (value == null || value.isEmpty()) { + return Collections.emptyList().toArray(); + } + + try { + return value.stream() + .filter(Objects::nonNull) + .sorted() + .collect(Collectors.toList()) + .toArray(); + } catch (ClassCastException ex) { + log.warn( + "Unable to sort() collection - this may result in a non deterministic snapshot.\n" + + "Consider adding a custom serializer for this type via the JacksonSnapshotSerializer#configure() method.\n" + + ex.getMessage()); + return value.toArray(); + } + } + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java new file mode 100644 index 0000000..a1a1078 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java @@ -0,0 +1,24 @@ +package au.com.origin.snapshots.jackson3.serializers.v1; + +import tools.jackson.databind.MapperFeature; +import tools.jackson.databind.json.JsonMapper; + +/** + * Attempts to deterministically render a snapshot. + * + *

This can help in situations where collections are rendering in a different order on subsequent + * runs. + * + *

Note that collections will be ordered which mar or may not be desirable given your use case. + */ +public class DeterministicJacksonSnapshotSerializer extends JacksonSnapshotSerializer { + + /** + * @param builder the builder to be built + */ + @Override + public void configure(final JsonMapper.Builder builder) { + builder.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY); + builder.addModule(new DeterministicCollectionModule()); + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java b/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java new file mode 100644 index 0000000..f1a0818 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java @@ -0,0 +1,100 @@ +package au.com.origin.snapshots.jackson3.serializers.v1; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.exceptions.SnapshotExtensionException; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonInclude; +import tools.jackson.core.util.DefaultIndenter; +import tools.jackson.core.util.DefaultPrettyPrinter; +import tools.jackson.core.util.Separators; +import tools.jackson.databind.SerializationFeature; +import tools.jackson.databind.cfg.DateTimeFeature; +import tools.jackson.databind.json.JsonMapper; + +import java.util.Arrays; +import java.util.List; + +public class JacksonSnapshotSerializer implements SnapshotSerializer { + private final JsonMapper jsonMapper = createMapper(); + + static DefaultPrettyPrinter.Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n"); + + private static final DefaultPrettyPrinter pp = new DefaultPrettyPrinter() { + { + this.indentArraysWith(lfOnlyIndenter); + this.indentObjectsWith(lfOnlyIndenter); + + Separators separators = Separators.createDefaultInstance() + .withRootSeparator(""); + this.withSeparators(separators); + } + + // It's a requirement + // @see https://github.com/FasterXML/jackson-databind/issues/2203 + public DefaultPrettyPrinter createInstance() { + return new DefaultPrettyPrinter(this); + } + }.withArrayIndenter(lfOnlyIndenter); + + private JsonMapper createMapper() { + JsonMapper.Builder builder = + JsonMapper.builder() + .defaultPrettyPrinter(pp) + .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS) + .enable(DateTimeFeature.WRITE_DATES_WITH_ZONE_ID) + .disable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS) + .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) + .changeDefaultPropertyInclusion(incl -> incl.withValueInclusion(JsonInclude.Include.NON_NULL)) + .changeDefaultPropertyInclusion(incl -> incl.withContentInclusion(JsonInclude.Include.NON_NULL)) + .changeDefaultVisibility(visibility -> + visibility.withFieldVisibility(JsonAutoDetect.Visibility.ANY) + .withGetterVisibility(JsonAutoDetect.Visibility.NONE) + .withSetterVisibility(JsonAutoDetect.Visibility.NONE) + .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); + + if (shouldFindAndRegisterModules()) { + builder.findAndAddModules(); + } + + configure(builder); + + return builder.build(); + } + + /** + * Override to customize the Jackson jsonMapper + * + * @param builder the builder to be built + */ + public void configure(final JsonMapper.Builder builder) { + } + + /** + * Override to control the registration of all available jackson modules within the classpath + * which are locatable via JDK ServiceLoader facility, along with module-provided SPI. + */ + protected boolean shouldFindAndRegisterModules() { + return true; + } + + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + try { + List objects = Arrays.asList(object); + + String body = jsonMapper.writerWithDefaultPrettyPrinter() + .writeValueAsString(objects); + return gen.toSnapshot(body); + } catch (Exception e) { + throw new SnapshotExtensionException("Jackson Serialization failed", e); + } + } + + @Override + public String getOutputFormat() { + return SerializerType.JSON.name(); + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java new file mode 100644 index 0000000..78ed811 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java @@ -0,0 +1,24 @@ +package au.com.origin.snapshots.jackson3; + +import static org.assertj.core.api.Assertions.assertThat; + +import au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer; +import au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; +import org.junit.jupiter.api.Test; + +/** + * These classes are likely defined in snapshot.properties as a string. + * + *

The clients IDE will not complain if they change so ensure they don't + */ +public class NoNameChangeTest { + + @Test + public void serializersApiShouldNotChange() { + assertThat(JacksonSnapshotSerializer.class.getName()) + .isEqualTo("au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer"); + assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) + .isEqualTo( + "au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer"); + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java new file mode 100644 index 0000000..b129663 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java @@ -0,0 +1,30 @@ +package au.com.origin.snapshots.jackson3; + +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import java.lang.reflect.Method; +import java.util.Optional; +import java.util.stream.Stream; + +public class ReflectionUtilities { + + // FIXME consider guava reflection instead + public static Method getMethod(Class clazz, String methodName) { + try { + return Stream.of(clazz.getDeclaredMethods()) + .filter(method -> method.getName().equals(methodName)) + .findFirst() + .orElseThrow(() -> new NoSuchMethodException("Not Found")); + } catch (NoSuchMethodException e) { + return Optional.ofNullable(clazz.getSuperclass()) + .map(superclass -> getMethod(superclass, methodName)) + .orElseThrow( + () -> + new SnapshotMatchException( + "Could not find method " + + methodName + + " on class " + + clazz + + "\nPlease annotate your test method with @Test and make it without any parameters!")); + } + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java new file mode 100644 index 0000000..46da813 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java @@ -0,0 +1,15 @@ +package au.com.origin.snapshots.jackson3.docs; + +import java.time.Instant; +import lombok.AllArgsConstructor; +import lombok.Data; + +// Example base class used by all hibernate entities +@Data +@AllArgsConstructor +public class BaseEntity { + private Long id; + private Instant createdDate; + private Instant lastModifiedDate; + private String somethingElse; +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java new file mode 100644 index 0000000..2d2caa5 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java @@ -0,0 +1,25 @@ +package au.com.origin.snapshots.jackson3.docs; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.SnapshotVerifier; +import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import java.time.Instant; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +public class CustomSerializerTest { + + @Test + public void test1(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier( + new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); + + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect + .serializer(HibernateSnapshotSerializer.class) + .toMatchSnapshot(new BaseEntity(1L, Instant.now(), Instant.now(), "This should render")); + + snapshotVerifier.validateSnapshots(); + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java new file mode 100644 index 0000000..b8c7144 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java @@ -0,0 +1,40 @@ +package au.com.origin.snapshots.jackson3.docs; + +import au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreType; +import tools.jackson.databind.json.JsonMapper; + +import java.time.Instant; +import java.util.List; +import java.util.Set; + +public class HibernateSnapshotSerializer extends DeterministicJacksonSnapshotSerializer { + + @Override + public void configure(final JsonMapper.Builder builder) { + super.configure(builder); + + // Ignore Hibernate Lists to prevent infinite recursion + builder.addMixIn(List.class, IgnoreTypeMixin.class); + builder.addMixIn(Set.class, IgnoreTypeMixin.class); + + // Ignore Fields that Hibernate generates for us automatically + builder.addMixIn(BaseEntity.class, IgnoreHibernateEntityFields.class); + } + + @JsonIgnoreType + class IgnoreTypeMixin { + } + + abstract class IgnoreHibernateEntityFields { + @JsonIgnore + abstract Long getId(); + + @JsonIgnore + abstract Instant getCreatedDate(); + + @JsonIgnore + abstract Instant getLastModifiedDate(); + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java new file mode 100644 index 0000000..f2a157a --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java @@ -0,0 +1,21 @@ +package au.com.origin.snapshots.jackson3.docs; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import au.com.origin.snapshots.serializers.SerializerType; +import lombok.SneakyThrows; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; + +public class JsonAssertReporter implements SnapshotReporter { + @Override + public boolean supportsFormat(String outputFormat) { + return SerializerType.JSON.name().equalsIgnoreCase(outputFormat); + } + + @Override + @SneakyThrows + public void report(Snapshot previous, Snapshot current) { + JSONAssert.assertEquals(previous.getBody(), current.getBody(), JSONCompareMode.STRICT); + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java new file mode 100644 index 0000000..3a61708 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java @@ -0,0 +1,19 @@ +package au.com.origin.snapshots.jackson3.docs; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.comparators.SnapshotComparator; +import lombok.SneakyThrows; +import tools.jackson.databind.json.JsonMapper; + +public class JsonObjectComparator implements SnapshotComparator { + @Override + public boolean matches(Snapshot previous, Snapshot current) { + return asObject(previous.getName(), previous.getBody()) + .equals(asObject(current.getName(), current.getBody())); + } + + @SneakyThrows + private static Object asObject(String snapshotName, String json) { + return new JsonMapper().readValue(json.replaceFirst(snapshotName + "=", ""), Object.class); + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap new file mode 100644 index 0000000..84dc2ac --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap @@ -0,0 +1,5 @@ +au.com.origin.snapshots.jackson3.docs.CustomSerializerTest.test1=[ + { + "somethingElse" : "This should render" + } +] \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java new file mode 100644 index 0000000..788917c --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java @@ -0,0 +1,141 @@ +package au.com.origin.snapshots.jackson3.serializers.v1; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.SnapshotVerifier; +import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import au.com.origin.snapshots.serializers.SerializerType; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.util.*; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +public class DeterministicJacksonSnapshotSerializerTest { + + @Test + public void shouldSerializeDifferentTypes(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier( + new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer("orderedJson").toMatchSnapshot(new TypeDummy()); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldSupportJsonFormat() { + Assertions.assertThat(new DeterministicJacksonSnapshotSerializer().getOutputFormat()) + .isEqualTo(SerializerType.JSON.name()); + } + + private Map nonDeterministicMap(Map target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + + int size = items.size(); + for (int i = 0; i < size; i++) { + String random = pluckRandom(items); + target.put(random, (int) random.charAt(0)); + } + return target; + } + + private Collection nonDeterministicCollection(Collection target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + + int size = items.size(); + for (int i = 0; i < size; i++) { + target.add(pluckRandom(items)); + } + + return target; + } + + private String pluckRandom(List array) { + int rnd = new Random().nextInt(array.size()); + return array.remove(rnd); + } + + private enum AnEnum { + F, + A, + D, + E, + G, + B, + C; + } + + private final class TypeDummy { + private final Void aNull = null; + private final Object anObject = new Object(); + private final byte aByte = "A".getBytes()[0]; + private final short aShort = 32767; + private final int anInt = 2147483647; + private final long aLong = 9223372036854775807L; + private final float aFloat = 0.1234567F; + private final double aDouble = 1.123456789123456D; + private final boolean aBoolean = true; + private final char aChar = 'A'; + private final String string = "Hello World"; + private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); + private final LocalDate localDate = LocalDate.parse("2020-10-19"); + private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); + private final ZonedDateTime zonedDateTime = + ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); + private final AnEnum anEnum = AnEnum.A; + private final Optional presentOptional = Optional.of("Hello World"); + private final Optional emptyOptional = Optional.empty(); + private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; + private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); + + // Maps + private final Map hashMap = nonDeterministicMap(new HashMap<>()); + private final Map treeMap = nonDeterministicMap(new TreeMap<>()); + private final Map linkedHashMap = nonDeterministicMap(new LinkedHashMap<>()); + + // Sets + private final Collection linkedHashSet = + nonDeterministicCollection(new LinkedHashSet<>()); + private final Collection hashSet = nonDeterministicCollection(new HashSet<>()); + private final Collection treeSet = nonDeterministicCollection(new TreeSet<>()); + + // Lists + private final Collection arrayList = nonDeterministicCollection(new ArrayList<>()); + private final Collection linkedList = nonDeterministicCollection(new LinkedList<>()); + + // Mixed Maps, Sets, Lists + private final Collection listOfCollections = + new ArrayList() { + { + add(nonDeterministicMap(new LinkedHashMap<>())); + add(nonDeterministicCollection(new LinkedHashSet<>())); + add(nonDeterministicCollection(new LinkedList<>())); + } + }; + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java new file mode 100644 index 0000000..e3d2a89 --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java @@ -0,0 +1,155 @@ +package au.com.origin.snapshots.jackson3.serializers.v1; + +import au.com.origin.snapshots.*; +import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.util.*; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +public class JacksonSnapshotSerializerTest { + + private static final SnapshotConfig DEFAULT_CONFIG = + new PropertyResolvingSnapshotConfig() { + @Override + public SnapshotSerializer getSerializer() { + return new JacksonSnapshotSerializer(); + } + }; + + private SnapshotSerializerContext gen = + new SnapshotSerializerContext( + "test", null, new SnapshotHeader(), JacksonSnapshotSerializerTest.class, null); + + @Test + public void shouldSerializeMap() { + Map map = new HashMap<>(); + map.put("name", "John Doe"); + map.put("age", 40); + + SnapshotSerializer serializer = new JacksonSnapshotSerializer(); + Snapshot result = serializer.apply(map, gen); + Assertions.assertThat(result.getBody()) + .isEqualTo( + "[\n" + + " {\n" + + " \"age\" : 40,\n" + + " \"name\" : \"John Doe\"\n" + + " }\n" + + "]"); + } + + @Test + public void shouldSerializeDifferentTypes(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(new TypeDummy()); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldSupportJsonFormat() { + Assertions.assertThat(new JacksonSnapshotSerializer().getOutputFormat()) + .isEqualTo(SerializerType.JSON.name()); + } + + private Map deterministicMap(Map target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + items.forEach(it -> target.put(it, (int) it.charAt(0))); + return target; + } + + private Collection deterministicCollection(Collection target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + target.addAll(items); + return target; + } + + private enum AnEnum { + F, + A, + D, + E, + G, + B, + C; + } + + private final class TypeDummy { + private final Void aNull = null; + private final Object anObject = new Object(); + private final byte aByte = "A".getBytes()[0]; + private final short aShort = 32767; + private final int anInt = 2147483647; + private final long aLong = 9223372036854775807L; + private final float aFloat = 0.1234567F; + private final double aDouble = 1.123456789123456D; + private final boolean aBoolean = true; + private final char aChar = 'A'; + private final String string = "Hello World"; + private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); + private final LocalDate localDate = LocalDate.parse("2020-10-19"); + private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); + private final ZonedDateTime zonedDateTime = + ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); + private final AnEnum anEnum = AnEnum.A; + private final Optional presentOptional = Optional.of("Hello World"); + private final Optional emptyOptional = Optional.empty(); + private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; + private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); + + // Maps + private final Map hashMap = deterministicMap(new HashMap<>()); + private final Map treeMap = deterministicMap(new TreeMap<>()); + private final Map linkedHashMap = deterministicMap(new LinkedHashMap<>()); + + // Sets + private final Collection linkedHashSet = deterministicCollection(new LinkedHashSet<>()); + private final Collection hashSet = deterministicCollection(new HashSet<>()); + private final Collection treeSet = deterministicCollection(new TreeSet<>()); + + // Lists + private final Collection arrayList = deterministicCollection(new ArrayList<>()); + private final Collection linkedList = deterministicCollection(new LinkedList<>()); + + // Mixed Maps, Sets, Lists + private final Collection listOfCollections = + new ArrayList() { + { + add(deterministicMap(new LinkedHashMap<>())); + add(deterministicCollection(new LinkedHashSet<>())); + add(deterministicCollection(new LinkedList<>())); + } + }; + } +} diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap new file mode 100644 index 0000000..e785b8f --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap @@ -0,0 +1,140 @@ +au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap new file mode 100644 index 0000000..4cbc79b --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap @@ -0,0 +1,140 @@ +au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson3/src/test/resources/snapshot.properties b/java-snapshot-testing-plugin-jackson3/src/test/resources/snapshot.properties new file mode 100644 index 0000000..0ba48cb --- /dev/null +++ b/java-snapshot-testing-plugin-jackson3/src/test/resources/snapshot.properties @@ -0,0 +1,8 @@ +serializer=au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer +serializer.orderedJson=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer +comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator +reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter +snapshot-dir=__snapshots__ +output-dir=src/test/java +ci-env-var=CI +update-snapshot=none \ No newline at end of file diff --git a/java-snapshot-testing-spock/build.gradle b/java-snapshot-testing-spock/build.gradle index 9f05cbf..3f59637 100644 --- a/java-snapshot-testing-spock/build.gradle +++ b/java-snapshot-testing-spock/build.gradle @@ -9,18 +9,22 @@ dependencies { implementation project(':java-snapshot-testing-core') // User supplied Spock Version - compileOnly 'org.codehaus.groovy:groovy-all:2.5.8' - compileOnly 'org.spockframework:spock-core:1.3-groovy-2.5' + compileOnly "org.codehaus.groovy:groovy:3.0.21" + compileOnly "org.spockframework:spock-core:2.3-groovy-3.0" // Testing testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' - testImplementation 'org.codehaus.groovy:groovy-all:2.5.8' - testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5' + testImplementation "org.codehaus.groovy:groovy:3.0.21" + testImplementation "org.spockframework:spock-core:2.3-groovy-3.0" testImplementation 'org.assertj:assertj-core:3.11.1' // Required java-snapshot-testing peer dependencies - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3' + testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' + testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' +} + +tasks.withType(Test).configureEach { + useJUnitPlatform() } publishing { diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy index c5f7389..ed69922 100644 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy +++ b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy @@ -1,10 +1,7 @@ package au.com.origin.snapshots -import org.junit.runner.RunWith -import org.spockframework.runtime.Sputnik import spock.lang.Specification -@RunWith(Sputnik.class) class SpecificationBase extends Specification { - Expect expect; -} + Expect expect +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 05e3e32..8c2ac17 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,3 @@ rootProject.name = 'java-snapshot-testing' -include 'java-snapshot-testing-core', 'java-snapshot-testing-junit4', 'java-snapshot-testing-junit5', 'java-snapshot-testing-spock', 'java-snapshot-testing-plugin-jackson' \ No newline at end of file +include 'java-snapshot-testing-core', 'java-snapshot-testing-junit4', 'java-snapshot-testing-junit5', 'java-snapshot-testing-spock', 'java-snapshot-testing-plugin-jackson', 'java-snapshot-testing-plugin-jackson3' \ No newline at end of file From 597e17400897f1efb9645baa8b6b8643dd9a3d16 Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Fri, 23 Jan 2026 11:00:51 +0100 Subject: [PATCH 5/9] chore: migrate to new group and introduce maven --- .github/dependabot.yml | 11 - .github/workflows/build.yml | 64 ---- .github/workflows/codeql.yml | 74 ----- .github/workflows/release.yml | 58 ---- .gitignore | 131 +++++++- .mvn/maven.config | 4 + .mvn/settings.xml | 12 + .mvn/wrapper/maven-wrapper.properties | 18 ++ CONTRIBUTING.md | 89 ------ LATEST_SNAPSHOT.md | 20 -- LICENSE | 21 -- build.gradle | 48 --- gradle.properties | 2 - gradle/publishing.gradle | 119 -------- gradle/spotless-groovy.gradle | 10 - gradle/spotless.gradle | 11 - gradle/wrapper/gradle-wrapper.jar | Bin 55616 -> 0 bytes gradle/wrapper/gradle-wrapper.properties | 5 - gradlew | 188 ------------ gradlew.bat | 100 ------ java-snapshot-testing-core/build.gradle | 30 -- .../java/au/com/origin/snapshots/Expect.java | 172 ----------- .../au/com/origin/snapshots/Snapshot.java | 80 ----- .../com/origin/snapshots/SnapshotContext.java | 173 ----------- .../au/com/origin/snapshots/SnapshotFile.java | 169 ----------- .../com/origin/snapshots/SnapshotHeader.java | 48 --- .../origin/snapshots/SnapshotProperties.java | 58 ---- .../snapshots/SnapshotSerializerContext.java | 43 --- .../origin/snapshots/SnapshotVerifier.java | 146 --------- .../snapshots/annotations/SnapshotName.java | 11 - .../annotations/UseSnapshotConfig.java | 12 - .../PropertyResolvingSnapshotConfig.java | 77 ----- .../snapshots/config/SnapshotConfig.java | 86 ------ .../exceptions/LogGithubIssueException.java | 12 - ...MissingSnapshotPropertiesKeyException.java | 8 - .../exceptions/ReservedWordException.java | 18 -- .../SnapshotExtensionException.java | 12 - .../exceptions/SnapshotMatchException.java | 20 -- .../snapshots/logging/LoggingHelper.java | 13 - .../v1/PlainTextSnapshotReporter.java | 40 --- .../v1/Base64SnapshotSerializer.java | 35 --- .../v1/ToStringSnapshotSerializer.java | 33 -- .../snapshots/utils/ReflectionUtils.java | 48 --- .../snapshots/CustomFolderSnapshotTest.java | 63 ---- .../DebugSnapshotLineEndingsTest.java | 96 ------ .../origin/snapshots/DebugSnapshotTest.java | 111 ------- .../snapshots/EmptySnapshotFileTest.java | 58 ---- .../snapshots/EqualDebugSnapshotFileTest.java | 38 --- .../au/com/origin/snapshots/FakeObject.java | 25 -- .../origin/snapshots/NoNameChangeTest.java | 40 --- .../snapshots/OnLoadSnapshotFileTest.java | 71 ----- .../origin/snapshots/OrphanSnapshotTest.java | 75 ----- .../snapshots/PrivateCalledMethodTest.java | 24 -- .../origin/snapshots/ReflectionUtilities.java | 30 -- .../au/com/origin/snapshots/ScenarioTest.java | 56 ---- .../com/origin/snapshots/SnapshotCaptor.java | 104 ------- .../origin/snapshots/SnapshotContextTest.java | 230 -------------- .../com/origin/snapshots/SnapshotHeaders.java | 59 ---- .../snapshots/SnapshotIntegrationTest.java | 93 ------ .../SnapshotMatcherScenarioTest.java | 65 ---- .../origin/snapshots/SnapshotMatcherTest.java | 64 ---- .../snapshots/SnapshotNameAnnotationTest.java | 95 ------ ...pshotNameAnnotationWithDuplicatesTest.java | 24 -- .../snapshots/SnapshotOverrideClassTest.java | 24 -- .../snapshots/SnapshotSuperClassTest.java | 18 -- .../au/com/origin/snapshots/SnapshotTest.java | 95 ------ .../com/origin/snapshots/SnapshotUtils.java | 105 ------- .../origin/snapshots/SnapshotUtilsTest.java | 75 ----- .../snapshots/UpdateSnapshotPropertyTest.java | 90 ------ .../origin/snapshots/UpdateSnapshotTest.java | 153 ---------- .../origin/snapshots/UseCustomConfigTest.java | 39 --- .../snapshots/UseCustomSerializerTest.java | 49 --- .../PlainTextEqualsComparatorTest.java | 24 -- .../snapshots/config/BaseSnapshotConfig.java | 43 --- .../config/ToStringSnapshotConfig.java | 24 -- .../EmptySnapshotFileTest.snap.debug | 0 .../EqualDebugSnapshotFileTest.snap.debug | 13 - .../__snapshots__/SnapshotUtilsTest.snap | 13 - .../PlainTextSnapshotReporterTest.java | 34 --- .../Base64SnapshotSerializerTest.java | 54 ---- .../ToStringSnapshotSerializerTest.java | 89 ------ java-snapshot-testing-junit4/build.gradle | 30 -- .../junit4/SharedSnapshotHelpers.java | 58 ---- .../snapshots/junit4/SnapshotClassRule.java | 29 -- .../origin/snapshots/junit4/SnapshotRule.java | 32 -- .../snapshots/junit4/SnapshotRunner.java | 73 ----- .../com/origin/snapshots/BaseClassTest.java | 23 -- .../java/au/com/origin/snapshots/MyTest.java | 20 -- .../origin/snapshots/ParameterizedTest.java | 38 --- .../snapshots/SnapshotRuleUsedTest.java | 33 -- .../snapshots/__snapshots__/MyTest.snap | 3 - .../__snapshots__/ParameterizedTest.snap | 13 - .../SnapshotContextRuleUsedTest.snap | 31 -- .../__snapshots__/SnapshotRuleUsedTest.snap | 13 - .../__snapshots__/SnapshotRunnerUsedTest.snap | 28 -- .../snapshots/docs/JUnit4RulesExample.java | 25 -- .../docs/__snapshots__/JUnit4Example.snap | 8 - .../__snapshots__/JUnit4RulesExample.snap | 3 - java-snapshot-testing-junit5/build.gradle | 38 --- ...dClassTest$NestedClassWithoutSnapshot.snap | 3 - .../build.gradle | 40 --- .../build.gradle | 53 ---- java-snapshot-testing-spock/build.gradle | 38 --- .../snapshots/spock/EnableSnapshots.groovy | 13 - .../snapshots/spock/SnapshotExtension.groovy | 28 -- .../spock/SnapshotMethodInterceptor.groovy | 58 ---- .../origin/snapshots/SpecificationBase.groovy | 7 - .../snapshots/SpockExtensionUsedSpec.groovy | 79 ----- .../com/origin/snapshots/TestBaseSpec.groovy | 18 -- .../__snapshots__/SpockExtensionUsedSpec.snap | 38 --- .../snapshots/__snapshots__/TestBaseSpec.snap | 3 - .../origin/snapshots/docs/SpockExample.groovy | 34 --- .../docs/SpockWithParametersExample.groovy | 25 -- .../docs/__snapshots__/SpockExample.snap | 8 - .../SpockWithParametersExample.snap | 8 - .../src/test/resources/snapshot.properties | 7 - mvnw | 287 ++++++++++++++++++ mvnw.cmd | 187 ++++++++++++ pom.xml | 267 ++++++++++++++++ settings.gradle | 3 - .../.gitignore | 0 snapshot-testing-core/pom.xml | 115 +++++++ .../java/au/com/origin/snapshots/Expect.java | 173 +++++++++++ .../au/com/origin/snapshots/Snapshot.java | 81 +++++ .../com/origin/snapshots/SnapshotContext.java | 186 ++++++++++++ .../au/com/origin/snapshots/SnapshotFile.java | 171 +++++++++++ .../com/origin/snapshots/SnapshotHeader.java | 49 +++ .../origin/snapshots/SnapshotProperties.java | 59 ++++ .../snapshots/SnapshotSerializerContext.java | 52 ++++ .../origin/snapshots/SnapshotVerifier.java | 153 ++++++++++ .../snapshots/annotations/SnapshotName.java | 16 + .../annotations/UseSnapshotConfig.java | 18 ++ .../PlainTextEqualsComparator.java | 12 +- .../comparators/SnapshotComparator.java | 2 +- .../v1/PlainTextEqualsComparator.java | 8 +- .../PropertyResolvingSnapshotConfig.java | 78 +++++ .../snapshots/config/SnapshotConfig.java | 88 ++++++ .../config/SnapshotConfigInjector.java | 2 +- .../exceptions/LogGithubIssueException.java | 12 + ...MissingSnapshotPropertiesKeyException.java | 8 + .../exceptions/ReservedWordException.java | 18 ++ .../SnapshotExtensionException.java | 12 + .../exceptions/SnapshotMatchException.java | 21 ++ .../snapshots/logging/LoggingHelper.java | 13 + .../reporters/PlainTextSnapshotReporter.java | 12 +- .../snapshots/reporters/SnapshotReporter.java | 4 +- .../v1/PlainTextSnapshotReporter.java | 41 +++ .../serializers/Base64SnapshotSerializer.java | 12 +- .../snapshots/serializers/SerializerType.java | 6 +- .../serializers/SnapshotSerializer.java | 3 +- .../ToStringSnapshotSerializer.java | 12 +- .../v1/Base64SnapshotSerializer.java | 36 +++ .../v1/ToStringSnapshotSerializer.java | 33 ++ .../snapshots/utils/ReflectionUtils.java | 49 +++ .../snapshots/CustomFolderSnapshotTest.java | 64 ++++ .../DebugSnapshotLineEndingsTest.java | 97 ++++++ .../origin/snapshots/DebugSnapshotTest.java | 116 +++++++ .../snapshots/EmptySnapshotFileTest.java | 63 ++++ .../snapshots/EqualDebugSnapshotFileTest.java | 39 +++ .../au/com/origin/snapshots/FakeObject.java | 34 +++ .../origin/snapshots/NoNameChangeTest.java | 40 +++ .../snapshots/OnLoadSnapshotFileTest.java | 72 +++++ .../origin/snapshots/OrphanSnapshotTest.java | 76 +++++ .../snapshots/PrivateCalledMethodTest.java | 24 ++ .../origin/snapshots/ReflectionUtilities.java | 31 ++ .../au/com/origin/snapshots/ScenarioTest.java | 56 ++++ .../com/origin/snapshots/SnapshotCaptor.java | 105 +++++++ .../origin/snapshots/SnapshotContextTest.java | 231 ++++++++++++++ .../com/origin/snapshots/SnapshotHeaders.java | 59 ++++ .../snapshots/SnapshotIntegrationTest.java | 93 ++++++ .../SnapshotMatcherScenarioTest.java | 66 ++++ .../origin/snapshots/SnapshotMatcherTest.java | 65 ++++ .../snapshots/SnapshotNameAnnotationTest.java | 95 ++++++ ...pshotNameAnnotationWithDuplicatesTest.java | 25 ++ .../snapshots/SnapshotOverrideClassTest.java | 24 ++ .../snapshots/SnapshotSuperClassTest.java | 20 ++ .../au/com/origin/snapshots/SnapshotTest.java | 95 ++++++ .../com/origin/snapshots/SnapshotUtils.java | 106 +++++++ .../origin/snapshots/SnapshotUtilsTest.java | 77 +++++ .../snapshots/UpdateSnapshotPropertyTest.java | 94 ++++++ .../origin/snapshots/UpdateSnapshotTest.java | 154 ++++++++++ .../origin/snapshots/UseCustomConfigTest.java | 39 +++ .../snapshots/UseCustomSerializerTest.java | 49 +++ .../PlainTextEqualsComparatorTest.java | 24 ++ .../snapshots/config/BaseSnapshotConfig.java | 44 +++ .../config/ToStringSnapshotConfig.java | 24 ++ .../DebugSnapshotLineEndingsTest.snap | 0 .../__snapshots__/DebugSnapshotTest.snap | 0 .../EmptySnapshotFileTest$NestedClass.snap | 0 .../__snapshots__/EmptySnapshotFileTest.snap | 0 .../EqualDebugSnapshotFileTest.snap | 0 .../__snapshots__/OrphanSnapshotTest.snap | 0 .../PrivateCalledMethodTest.snap | 0 .../__snapshots__/README.md | 0 .../__snapshots__/ScenarioTest.snap | 0 .../__snapshots__/SnapshotHeaders.snap | 0 .../SnapshotIntegrationTest.snap | 0 .../SnapshotNameAnnotationTest.snap | 0 .../SnapshotOverrideClassTest.snap | 0 .../__snapshots__/SnapshotUtilsTest.snap | 0 .../UpdateSnapshotPropertyTest.snap | 0 .../__snapshots__/UseCustomConfigTest.snap | 0 .../UseCustomSerializerTest.snap | 0 .../PlainTextSnapshotReporterTest.java | 34 +++ .../Base64SnapshotSerializerTest.java | 55 ++++ .../LowercaseToStringSerializer.java | 16 + .../ToStringSnapshotSerializerTest.java | 89 ++++++ .../UppercaseToStringSerializer.java | 16 + .../src/test/resources/origin-logo.png | Bin .../src/test/resources/snapshot.properties | 0 snapshot-testing-jackson/pom.xml | 165 ++++++++++ .../DeterministicCollectionModule.java | 0 ...eterministicJacksonSnapshotSerializer.java | 0 .../JacksonSnapshotSerializer.java | 0 ...eterministicJacksonSnapshotSerializer.java | 11 +- .../v1/JacksonSnapshotSerializer.java | 0 .../serializers/v1/SnapshotPrettyPrinter.java | 0 .../snapshots/jackson/NoNameChangeTest.java | 0 .../jackson/ReflectionUtilities.java | 0 .../snapshots/jackson/docs/BaseEntity.java | 0 .../jackson/docs/CustomSerializerTest.java | 0 .../docs/HibernateSnapshotSerializer.java | 0 .../jackson/docs/JsonAssertReporter.java | 0 .../jackson/docs/JsonObjectComparator.java | 0 .../__snapshots__/CustomSerializerTest.snap | 0 ...ministicJacksonSnapshotSerializerTest.java | 0 .../JacksonSnapshotSerializerTest.java | 0 ...ministicJacksonSnapshotSerializerTest.snap | 0 .../JacksonSnapshotSerializerTest.snap | 0 .../src/test/resources/snapshot.properties | 0 snapshot-testing-jackson3/pom.xml | 153 ++++++++++ .../v1/DeterministicCollectionModule.java | 0 ...eterministicJacksonSnapshotSerializer.java | 0 .../v1/JacksonSnapshotSerializer.java | 0 .../snapshots/jackson3/NoNameChangeTest.java | 0 .../jackson3/ReflectionUtilities.java | 0 .../snapshots/jackson3/docs/BaseEntity.java | 0 .../jackson3/docs/CustomSerializerTest.java | 0 .../docs/HibernateSnapshotSerializer.java | 0 .../jackson3/docs/JsonAssertReporter.java | 0 .../jackson3/docs/JsonObjectComparator.java | 0 .../__snapshots__/CustomSerializerTest.snap | 0 ...ministicJacksonSnapshotSerializerTest.java | 0 .../v1/JacksonSnapshotSerializerTest.java | 0 ...ministicJacksonSnapshotSerializerTest.snap | 0 .../JacksonSnapshotSerializerTest.snap | 0 .../src/test/resources/snapshot.properties | 0 snapshot-testing-junit5/pom.xml | 137 +++++++++ .../snapshots/junit5/SnapshotExtension.java | 1 + .../com/origin/snapshots/BaseClassTest.java | 0 .../com/origin/snapshots/NestedClassTest.java | 0 .../snapshots/NestedClassTestWithExtends.java | 0 .../snapshots/SnapshotExtensionUsedTest.java | 0 .../snapshots/SnapshotParameterTest.java | 0 .../BaseClassTest$NestedClass.snap | 0 ...assTest$NestedClassWithExpectArgument.snap | 0 ...estedClassTestWithExtends$NestedClass.snap | 0 .../SnapshotExtensionUsedTest.snap | 0 .../__snapshots__/SnapshotParameterTest.snap | 0 .../docs/CustomFrameworkExample.java | 0 .../docs/CustomSnapshotConfigExample.java | 0 .../origin/snapshots/docs/JUnit5Example.java | 0 .../JUnit5ResolutionHierarchyExample.java | 0 .../docs/LowercaseToStringSerializer.java | 0 .../docs/LowercaseToStringSnapshotConfig.java | 0 .../snapshots/docs/MyFirstSnapshotTest.java | 0 .../com/origin/snapshots/docs/TestObject.java | 0 .../docs/UppercaseToStringSerializer.java | 0 .../__snapshots__/CustomFrameworkExample.snap | 0 .../CustomSnapshotConfigExample.snap | 0 .../CustomSnapshotContextConfigExample.snap | 0 .../docs/__snapshots__/JUnit5Example.snap | 0 .../JUnit5ResolutionHierarchyExample.snap | 0 .../MyFirstSnapshotContextTest.snap | 0 .../__snapshots__/MyFirstSnapshotTest.snap | 0 .../test/resources/junit-platform.properties | 0 .../src/test/resources/snapshot.properties | 0 snapshot-testing-junit6/pom.xml | 137 +++++++++ .../snapshots/junit5/SnapshotExtension.java | 128 ++++++++ .../com/origin/snapshots/BaseClassTest.java | 24 ++ .../com/origin/snapshots/NestedClassTest.java | 52 ++++ .../snapshots/NestedClassTestWithExtends.java | 35 +++ .../snapshots/SnapshotExtensionUsedTest.java | 20 +- .../snapshots/SnapshotParameterTest.java | 51 ++++ .../BaseClassTest$NestedClass.snap | 0 ...assTest$NestedClassWithExpectArgument.snap | 3 + ...estedClassTestWithExtends$NestedClass.snap | 3 + .../SnapshotExtensionUsedTest.snap | 28 ++ .../__snapshots__/SnapshotParameterTest.snap | 38 +++ .../docs/CustomFrameworkExample.java | 32 ++ .../docs/CustomSnapshotConfigExample.java | 18 ++ .../origin/snapshots/docs/JUnit5Example.java | 17 +- .../JUnit5ResolutionHierarchyExample.java | 34 +++ .../docs}/LowercaseToStringSerializer.java | 4 +- .../docs/LowercaseToStringSnapshotConfig.java | 12 + .../snapshots/docs/MyFirstSnapshotTest.java | 30 ++ .../com/origin/snapshots/docs/TestObject.java | 8 + .../docs}/UppercaseToStringSerializer.java | 4 +- .../__snapshots__/CustomFrameworkExample.snap | 3 + .../CustomSnapshotConfigExample.snap | 1 + .../CustomSnapshotContextConfigExample.snap | 1 + .../docs/__snapshots__/JUnit5Example.snap | 8 + .../JUnit5ResolutionHierarchyExample.snap | 9 + .../MyFirstSnapshotContextTest.snap | 11 + .../__snapshots__/MyFirstSnapshotTest.snap | 11 + .../test/resources/junit-platform.properties | 2 + .../src/test/resources/snapshot.properties | 1 + 307 files changed, 5990 insertions(+), 5562 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .mvn/maven.config create mode 100644 .mvn/settings.xml create mode 100644 .mvn/wrapper/maven-wrapper.properties delete mode 100644 CONTRIBUTING.md delete mode 100644 LATEST_SNAPSHOT.md delete mode 100644 LICENSE delete mode 100644 build.gradle delete mode 100644 gradle.properties delete mode 100644 gradle/publishing.gradle delete mode 100644 gradle/spotless-groovy.gradle delete mode 100644 gradle/spotless.gradle delete mode 100644 gradle/wrapper/gradle-wrapper.jar delete mode 100644 gradle/wrapper/gradle-wrapper.properties delete mode 100755 gradlew delete mode 100644 gradlew.bat delete mode 100644 java-snapshot-testing-core/build.gradle delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java delete mode 100644 java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java delete mode 100644 java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java delete mode 100644 java-snapshot-testing-junit4/build.gradle delete mode 100644 java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SharedSnapshotHelpers.java delete mode 100644 java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotClassRule.java delete mode 100644 java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRule.java delete mode 100644 java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRunner.java delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/BaseClassTest.java delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/MyTest.java delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/ParameterizedTest.java delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRuleUsedTest.java delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/MyTest.snap delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/ParameterizedTest.snap delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotContextRuleUsedTest.snap delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRuleUsedTest.snap delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRunnerUsedTest.snap delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4RulesExample.java delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4Example.snap delete mode 100644 java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4RulesExample.snap delete mode 100644 java-snapshot-testing-junit5/build.gradle delete mode 100644 java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap delete mode 100644 java-snapshot-testing-plugin-jackson/build.gradle delete mode 100644 java-snapshot-testing-plugin-jackson3/build.gradle delete mode 100644 java-snapshot-testing-spock/build.gradle delete mode 100644 java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/EnableSnapshots.groovy delete mode 100644 java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotExtension.groovy delete mode 100644 java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotMethodInterceptor.groovy delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpockExtensionUsedSpec.groovy delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/TestBaseSpec.groovy delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/SpockExtensionUsedSpec.snap delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/TestBaseSpec.snap delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockExample.groovy delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockWithParametersExample.groovy delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockExample.snap delete mode 100644 java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockWithParametersExample.snap delete mode 100644 java-snapshot-testing-spock/src/test/resources/snapshot.properties create mode 100755 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml delete mode 100644 settings.gradle rename {java-snapshot-testing-core => snapshot-testing-core}/.gitignore (100%) create mode 100644 snapshot-testing-core/pom.xml create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java (53%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java (68%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java (60%) create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java (68%) create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java (53%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java (55%) create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java (65%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java (70%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java (90%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java (63%) create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java create mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/README.md (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap (100%) rename java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug => snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap (100%) create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java create mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/resources/origin-logo.png (100%) rename {java-snapshot-testing-core => snapshot-testing-core}/src/test/resources/snapshot.properties (100%) create mode 100644 snapshot-testing-jackson/pom.xml rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java (73%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap (100%) rename {java-snapshot-testing-plugin-jackson => snapshot-testing-jackson}/src/test/resources/snapshot.properties (100%) create mode 100644 snapshot-testing-jackson3/pom.xml rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap (100%) rename {java-snapshot-testing-plugin-jackson3 => snapshot-testing-jackson3}/src/test/resources/snapshot.properties (100%) create mode 100644 snapshot-testing-junit5/pom.xml rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java (99%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/BaseClassTest.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/NestedClassTest.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java (100%) rename {java-snapshot-testing-junit4 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/TestObject.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/resources/junit-platform.properties (100%) rename {java-snapshot-testing-junit5 => snapshot-testing-junit5}/src/test/resources/snapshot.properties (100%) create mode 100644 snapshot-testing-junit6/pom.xml create mode 100644 snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java rename java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRunnerUsedTest.java => snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java (58%) create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java rename {java-snapshot-testing-junit5 => snapshot-testing-junit6}/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap (100%) create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java rename java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4Example.java => snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java (55%) create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java rename {java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers => snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs}/LowercaseToStringSerializer.java (72%) create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java rename {java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers => snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs}/UppercaseToStringSerializer.java (72%) create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap create mode 100644 snapshot-testing-junit6/src/test/resources/junit-platform.properties rename {java-snapshot-testing-junit4 => snapshot-testing-junit6}/src/test/resources/snapshot.properties (75%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 478c722..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: 2, -updates: - - package-ecosystem: "gradle" - directory: "/" - schedule: - interval: "weekly" - day: "friday" - assignees: - - "jackmatt2" - labels: - - "dependencies" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 19ea542..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,64 +0,0 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: build - -on: - push: - branches: - - master - - 'release/**' - pull_request: - branches: - - master - - 'release/**' - workflow_dispatch: - -jobs: - build: - name: Build - runs-on: ${{ matrix.os }} - strategy: - matrix: - java_version: [ '8' ] - os: [ ubuntu-latest, windows-latest, macOS-latest ] - steps: - - uses: actions/checkout@v2 - - name: Set up JDK ${{ matrix.java_version }} - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java_version }} - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build - deploy: - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - name: Deploy SNAPSHOT - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v1 - with: - java-version: 8 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Jar - run: ./gradlew shadowJar - - name: Generate tag version - uses: anothrNick/github-tag-action@v1 - id: tag_version_dry_run - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WITH_V: false - DRY_RUN: true - - name: publish - env: - SNAPSHOT_VERSION: ${{ steps.tag_version_dry_run.outputs.tag }}-SNAPSHOT - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY_ASCII_ARMOR }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_KEY_PASSPHRASE }} - MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }} - MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }} - run: ./gradlew signArchives uploadArchives -Pversion=$SNAPSHOT_VERSION -PossrhUsername=${MAVEN_CENTRAL_TOKEN_USERNAME} -PossrhPassword=${MAVEN_CENTRAL_TOKEN_PASSWORD} -Psign=true - diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 0c39799..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,74 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master" ] - schedule: - - cron: '34 22 * * 1' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'java' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 91958ef..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: release - -on: - workflow_dispatch: - -jobs: - release: - name: Release to Maven Central, Tag & Release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Generate tag version - uses: anothrNick/github-tag-action@v1 - id: tag_version_dry_run - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WITH_V: false - DRY_RUN: true - - name: Set up JDK 8 - uses: actions/setup-java@v1 - with: - java-version: 8 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Jar - env: - RELEASE_VERSION: ${{ steps.tag_version_dry_run.outputs.tag }} - run: ./gradlew shadowJar -Pversion=$RELEASE_VERSION - - name: Publish to Maven Central - env: - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY_ASCII_ARMOR }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_KEY_PASSPHRASE }} - MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }} - MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }} - RELEASE_VERSION: ${{ steps.tag_version_dry_run.outputs.tag }} - run: ./gradlew -Pversion=$RELEASE_VERSION signArchives uploadArchives -PossrhUsername=${MAVEN_CENTRAL_TOKEN_USERNAME} -PossrhPassword=${MAVEN_CENTRAL_TOKEN_PASSWORD} -Psign=true - - name: Close & Release Staging Repository - env: - MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }} - MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }} - run: ./gradlew closeAndReleaseRepository -PossrhUsername=${MAVEN_CENTRAL_TOKEN_USERNAME} -PossrhPassword=${MAVEN_CENTRAL_TOKEN_PASSWORD} - - name: Push new tag - uses: anothrNick/github-tag-action@v1 - id: tag_version - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WITH_V: false - DRY_RUN: false - - name: Build Changelog - id: github_release - uses: mikepenz/release-changelog-builder-action@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Github Release - uses: softprops/action-gh-release@v1 - with: - body: ${{steps.github_release.outputs.changelog}} - tag_name: ${{ steps.tag_version.outputs.tag }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2b04bac..704351e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,125 @@ -.gradle/ -build/ +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +TODO.md +.flattened-pom.xml +*.snap.debug -# Ignore Gradle GUI config -gradle-app.setting +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. + .idea/artifacts + .idea/compiler.xml + .idea/jarRepositories.xml + .idea/modules.xml + .idea/*.iml + .idea/modules -# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) -!gradle-wrapper.jar +# CMake +cmake-build-*/ -# Cache of project -.gradletasknamecache +# mpeltonen/sbt-idea plugin +.idea_modules/ -# IDE -.idea +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Windows template +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### macOS template +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +.idea/ +target/ diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 0000000..9b30a2c --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,4 @@ +--global-settings +.mvn/settings.xml +--settings +.mvn/settings.xml \ No newline at end of file diff --git a/.mvn/settings.xml b/.mvn/settings.xml new file mode 100644 index 0000000..169f6ac --- /dev/null +++ b/.mvn/settings.xml @@ -0,0 +1,12 @@ + + + + + central + ${env.OSSRH_USERNAME} + ${env.OSSRH_PASSWORD} + + + \ No newline at end of file diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..4f15c4d --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 020d4d1..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,89 +0,0 @@ -# Contributing - -We welcome contributions to this project by both internal and external parties - -## How to contribute - -1. Fork the repository into your own github account (external contributors) or create a new branch (internal - contributions) -1. Make your code changes -1. Ensure you commit message is descriptive as it acts as the changelog. Mark any breaking changes with `BREAKING`. - Include a rectification strategy if you introduce a `BREAKING` change. -1. Ensure `README.md` is updated if needed. All code samples in the README should have corresponding (actual sames) in the various docs/ folders -1. Submit a pull request back to `master` branch (or the branch you are contributing to) -1. Ensure Github Actions build passes -1. Await reviews -1. Once merged into `master` a `SNAPSHOT` build will be available for consumption - immediately [here](https://oss.sonatype.org/content/repositories/snapshots/io/github/origin-energy/). Note that - snapshots change regularly and cannot be relied upon. -1. Hard Releases will be made once enough features have been added. - -## Building - -```java -./gradlew spotlessApply shadowJar -``` - -## Deploying locally and deploying to `.m2/` - -``` -./gradlew publishToMavenLocal -``` - -Ensure you add `mavenLocal()` to your consuming project and the dependency verison matches that in your local `.m2` -folder - -# Uploading to maven central -see `.github/workflows/release.yml` - -# Uploading to maven central (manually) - -Gradle release plugin is not currently working so this is a manual process at the moment. - -# Setup GPG on your machine - -1. copy the GPG Private key into a file `private.key` -1. run - -``` -gpg --import private.key -cd ~/.gnupg -gpg -k -gpg --export-secret-key YOUR_KEY_ID > ~/.gnupg/secring.gpg -``` - -## Preparing - -1. Create a tag `X.X.X` -1. Update `gradle.properties` and remove `-SNAPSHOT` from the version number -1. Check this file into version control and push the branch to the remote -1. run - -``` -export SONAR_USERNAME=? -export SONAR_PASSWORD=? -export GPG_KEY_ID=? -export GPG_KEY_PASSPHRASE=? -export PATH_TO_SECRING_GPG=~/.gnupg/secring.gpg - -# I found shadowed classes are not included if you don't separate the gradle operations -./gradlew clean shadowJar -./gradlew signArchives uploadArchives -PossrhUsername=${SONAR_USERNAME} -PossrhPassword=${SONAR_PASSWORD} -Psigning.keyId=${GPG_KEY_ID} -Psigning.password=${GPG_KEY_PASSPHRASE} -Psigning.secretKeyRingFile=${PATH_TO_SECRING_GPG} -``` - -## Releasing [Full Tutorial](https://central.sonatype.org/pages/ossrh-guide.html) - -1. Login to SONAR (https://oss.sonatype.org) -1. Click 'Staging Repositories' and locate the 'iogithuborigin-energy' bundle -1. Review artifacts are correct in the 'Content' tab -1. Press the 'Close' and give a reason such as "Jack Matthews - Confirmed artifacts are OK" -1. Wait for about 1 min and press the 'Refresh button', if all sanity checks have passed the 'Release' button will be - visible -1. Press the 'Release' button and give a reason for releasing -1. Objects should be available in about 10 min (Longer for search.maven.org) - -## Cleanup - -1. Checkout master branch -1. Increment version number in `gradle.properties` -1. Create pull request for merge \ No newline at end of file diff --git a/LATEST_SNAPSHOT.md b/LATEST_SNAPSHOT.md deleted file mode 100644 index 0968795..0000000 --- a/LATEST_SNAPSHOT.md +++ /dev/null @@ -1,20 +0,0 @@ -# Using and testing the latest SNAPSHOT (excuse the pun) from maven central - -Gradle - -``` -repositories { - // ... - maven { - url "https://oss.sonatype.org/content/repositories/snapshots" - } -} - -dependencies { - // ... - - // Replace {FRAMEWORK} with you testing framework - // Replace {X.X.X} with the version number from `/gradle.properties` - testCompile "io.github.origin-energy:java-snapshot-testing-{FRAMEWORK}:{X.X.X}-SNAPSHOT" -} -``` \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 3b85842..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 André Bonna - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 20ec5f8..0000000 --- a/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -plugins { - id 'net.researchgate.release' version '2.6.0' apply false - id 'com.github.johnrengelman.shadow' version '5.2.0' apply false - id 'io.codearte.nexus-staging' version '0.22.0' - id "com.diffplug.spotless" version "6.11.0" apply false -} - -subprojects { subproject -> - // FIXME this plugin is currently not working for multi-module projects even when defined at the top level only - // Will need to release and TAG manually for now - subproject.apply plugin: 'net.researchgate.release' - subproject.apply plugin: 'java-library' - subproject.apply plugin: 'com.github.johnrengelman.shadow' - subproject.apply plugin: 'maven-publish' - - sourceCompatibility = '1.8' - targetCompatibility = '1.8' - - repositories { - mavenCentral() - } - - shadowJar { - classifier = '' - relocate 'org.assertj', 'shadow.org.assertj' - relocate 'org.opentest4j', 'shadow.org.opentest4j' - exclude "module-info.class" - } - - dependencies { - // Lombok - compileOnly 'org.projectlombok:lombok:1.18.20' - annotationProcessor 'org.projectlombok:lombok:1.18.20' - testCompileOnly 'org.projectlombok:lombok:1.18.20' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.20' - - // Logging implementation - compileOnly 'org.slf4j:slf4j-api:2.0.0-alpha0' - } - - // Add verbose logging for Github Actions - test { - testLogging { - events "passed", "skipped", "failed" - exceptionFormat "full" - } - } -} diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 7321d68..0000000 --- a/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -group=io.github.origin-energy -version=0.0.0-SNAPSHOT diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle deleted file mode 100644 index 5f690cd..0000000 --- a/gradle/publishing.gradle +++ /dev/null @@ -1,119 +0,0 @@ -import org.gradle.api.publish.maven.MavenPublication -import groovy.xml.XmlUtil - -tasks.register('javadocJar', Jar) { - archiveClassifier.set('javadoc') - from tasks.named('javadoc') -} - -tasks.register('sourcesJar', Jar) { - archiveClassifier.set('sources') - from sourceSets.main.allSource -} - -apply plugin: 'net.researchgate.release' - -// Maven Central Publishing (Gradle 7/8+) -if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) { - apply plugin: 'maven-publish' - - // If you're using the nexus-staging plugin elsewhere, keep this block. - // (This config is unrelated to Gradle's 'maven' plugin and is still fine.) - nexusStaging { - username project.property("ossrhUsername") - password project.property("ossrhPassword") - packageGroup 'io.github.origin-energy' - } - - // Ensure the shaded jar is what gets published as the main artifact. - // ShadowJar defaults to classifier "all". If you want the published jar to be the default artifact - // (no classifier), uncomment the next block. - // - // tasks.named('shadowJar') { - // archiveClassifier.set('') - // } - - publishing { - publications { - mavenJava(MavenPublication) { - // Publish the shaded jar instead of the plain jar - artifact(tasks.named('shadowJar')) - - // Attach sources + javadoc - artifact(tasks.named('sourcesJar')) - artifact(tasks.named('javadocJar')) - - pom { - name = 'java-snapsho-testing' - packaging = 'jar' - description = 'Snapshot Testing for Java' - url = 'https://github.com/origin-energy/java-snapshot-testing' - - scm { - connection = 'scm:git:https://github.com/origin-energy/java-snapshot-testing' - url = 'https://github.com/origin-energy/java-snapshot-testing' - } - - licenses { - license { - name = 'MIT License' - url = 'http://www.opensource.org/licenses/mit-license.php' - } - } - - developers { - developer { - id = 'jack.matthews' - name = 'Jack Matthews' - email = 'jack.matthews@origin.com.au' - } - } - - // We clear out all the dependencies because we have shadowed them inside the jar - withXml { - def root = asNode() - def deps = root.dependencies - if (deps) { - root.remove(deps) - } - } - } - } - } - - repositories { - maven { - def releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - def snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/") - url = version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl - - credentials { - username = project.property("ossrhUsername").toString() - password = project.property("ossrhPassword").toString() - } - } - } - } -} - -// Sign for Maven Central deployment (Gradle 7/8+) -if (project.hasProperty("sign")) { - apply plugin: 'signing' - - signing { - def signingKey = findProperty("signingKey") - def signingPassword = findProperty("signingPassword") - useInMemoryPgpKeys(signingKey, signingPassword) - - // Sign the publication (modern replacement for signing.signPom(deployment)) - // Only works if maven-publish is applied (i.e., ossrh creds are present) - if (plugins.hasPlugin('maven-publish')) { - sign publishing.publications.mavenJava - } - } - - // Keep the same intent: ensure shaded jar exists before publish/sign - tasks.matching { it.name.startsWith("publish") }.configureEach { - dependsOn tasks.named('shadowJar') - } -} diff --git a/gradle/spotless-groovy.gradle b/gradle/spotless-groovy.gradle deleted file mode 100644 index 2e4b04f..0000000 --- a/gradle/spotless-groovy.gradle +++ /dev/null @@ -1,10 +0,0 @@ -apply plugin: 'com.diffplug.spotless' - -// Code formatting -spotless { - groovy { - importOrder() - excludeJava() - greclipse() - } -} \ No newline at end of file diff --git a/gradle/spotless.gradle b/gradle/spotless.gradle deleted file mode 100644 index 24b8ba0..0000000 --- a/gradle/spotless.gradle +++ /dev/null @@ -1,11 +0,0 @@ -apply plugin: 'com.diffplug.spotless' - -// Code formatting -spotless { - java { - importOrder() - removeUnusedImports() - googleJavaFormat() - formatAnnotations() - } -} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 5c2d1cf016b3885f6930543d57b744ea8c220a1a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 55616 zcmafaW0WS*vSoFbZJS-TZP!<}ZQEV8ZQHihW!tvx>6!c9%-lQoy;&DmfdT@8fB*sl68LLCKtKQ283+jS?^Q-bNq|NIAW8=eB==8_)^)r*{C^$z z{u;{v?IMYnO`JhmPq7|LA_@Iz75S9h~8`iX>QrjrmMeu{>hn4U;+$dor zz+`T8Q0f}p^Ao)LsYq74!W*)&dTnv}E8;7H*Zetclpo2zf_f>9>HT8;`O^F8;M%l@ z57Z8dk34kG-~Wg7n48qF2xwPp;SOUpd1}9Moir5$VSyf4gF)Mp-?`wO3;2x9gYj59oFwG>?Leva43@e(z{mjm0b*@OAYLC`O9q|s+FQLOE z!+*Y;%_0(6Sr<(cxE0c=lS&-FGBFGWd_R<5$vwHRJG=tB&Mi8@hq_U7@IMyVyKkOo6wgR(<% zQw1O!nnQl3T9QJ)Vh=(`cZM{nsEKChjbJhx@UQH+G>6p z;beBQ1L!3Zl>^&*?cSZjy$B3(1=Zyn~>@`!j%5v7IBRt6X`O)yDpVLS^9EqmHxBcisVG$TRwiip#ViN|4( zYn!Av841_Z@Ys=T7w#>RT&iXvNgDq3*d?$N(SznG^wR`x{%w<6^qj&|g})La;iD?`M=p>99p><39r9+e z`dNhQ&tol5)P#;x8{tT47i*blMHaDKqJs8!Pi*F{#)9%USFxTVMfMOy{mp2ZrLR40 z2a9?TJgFyqgx~|j0eA6SegKVk@|Pd|_6P$HvwTrLTK)Re`~%kg8o9`EAE1oAiY5Jgo=H}0*D?tSCn^=SIN~fvv453Ia(<1|s07aTVVtsRxY6+tT3589iQdi^ zC92D$ewm9O6FA*u*{Fe_=b`%q`pmFvAz@hfF@OC_${IPmD#QMpPNo0mE9U=Ch;k0L zZteokPG-h7PUeRCPPYG%H!WswC?cp7M|w42pbtwj!m_&4%hB6MdLQe&}@5-h~! zkOt;w0BbDc0H!RBw;1UeVckHpJ@^|j%FBZlC} zsm?nFOT$`F_i#1_gh4|n$rDe>0md6HvA=B%hlX*3Z%y@a&W>Rq`Fe(8smIgxTGb#8 zZ`->%h!?QCk>v*~{!qp=w?a*};Y**1uH`)OX`Gi+L%-d6{rV?@}MU#qfCU(!hLz;kWH=0A%W7E^pA zD;A%Jg5SsRe!O*0TyYkAHe&O9z*Ij-YA$%-rR?sc`xz_v{>x%xY39!8g#!Z0#03H( z{O=drKfb0cbx1F*5%q81xvTDy#rfUGw(fesh1!xiS2XT;7_wBi(Rh4i(!rR^9=C+- z+**b9;icxfq@<7}Y!PW-0rTW+A^$o*#ZKenSkxLB$Qi$%gJSL>x!jc86`GmGGhai9 zOHq~hxh}KqQHJeN$2U{M>qd*t8_e&lyCs69{bm1?KGTYoj=c0`rTg>pS6G&J4&)xp zLEGIHSTEjC0-s-@+e6o&w=h1sEWWvJUvezID1&exb$)ahF9`(6`?3KLyVL$|c)CjS zx(bsy87~n8TQNOKle(BM^>1I!2-CZ^{x6zdA}qeDBIdrfd-(n@Vjl^9zO1(%2pP9@ zKBc~ozr$+4ZfjmzEIzoth(k?pbI87=d5OfjVZ`Bn)J|urr8yJq`ol^>_VAl^P)>2r)s+*3z5d<3rP+-fniCkjmk=2hTYRa@t zCQcSxF&w%mHmA?!vaXnj7ZA$)te}ds+n8$2lH{NeD4mwk$>xZCBFhRy$8PE>q$wS`}8pI%45Y;Mg;HH+}Dp=PL)m77nKF68FggQ-l3iXlVZuM2BDrR8AQbK;bn1%jzahl0; zqz0(mNe;f~h8(fPzPKKf2qRsG8`+Ca)>|<&lw>KEqM&Lpnvig>69%YQpK6fx=8YFj zHKrfzy>(7h2OhUVasdwKY`praH?>qU0326-kiSyOU_Qh>ytIs^htlBA62xU6xg?*l z)&REdn*f9U3?u4$j-@ndD#D3l!viAUtw}i5*Vgd0Y6`^hHF5R=No7j8G-*$NWl%?t z`7Nilf_Yre@Oe}QT3z+jOUVgYtT_Ym3PS5(D>kDLLas8~F+5kW%~ZYppSrf1C$gL* zCVy}fWpZ3s%2rPL-E63^tA|8OdqKsZ4TH5fny47ENs1#^C`_NLg~H^uf3&bAj#fGV zDe&#Ot%_Vhj$}yBrC3J1Xqj>Y%&k{B?lhxKrtYy;^E9DkyNHk5#6`4cuP&V7S8ce9 zTUF5PQIRO7TT4P2a*4;M&hk;Q7&{(83hJe5BSm=9qt~;U)NTf=4uKUcnxC`;iPJeI zW#~w?HIOM+0j3ptB0{UU{^6_#B*Q2gs;1x^YFey(%DJHNWz@e_NEL?$fv?CDxG`jk zH|52WFdVsZR;n!Up;K;4E$|w4h>ZIN+@Z}EwFXI{w_`?5x+SJFY_e4J@|f8U08%dd z#Qsa9JLdO$jv)?4F@&z_^{Q($tG`?|9bzt8ZfH9P`epY`soPYqi1`oC3x&|@m{hc6 zs0R!t$g>sR@#SPfNV6Pf`a^E?q3QIaY30IO%yKjx#Njj@gro1YH2Q(0+7D7mM~c>C zk&_?9Ye>B%*MA+77$Pa!?G~5tm`=p{NaZsUsOgm6Yzclr_P^2)r(7r%n(0?4B#$e7 z!fP;+l)$)0kPbMk#WOjm07+e?{E)(v)2|Ijo{o1+Z8#8ET#=kcT*OwM#K68fSNo%< zvZFdHrOrr;>`zq!_welWh!X}=oN5+V01WJn7=;z5uo6l_$7wSNkXuh=8Y>`TjDbO< z!yF}c42&QWYXl}XaRr0uL?BNPXlGw=QpDUMo`v8pXzzG(=!G;t+mfCsg8 zJb9v&a)E!zg8|%9#U?SJqW!|oBHMsOu}U2Uwq8}RnWeUBJ>FtHKAhP~;&T4mn(9pB zu9jPnnnH0`8ywm-4OWV91y1GY$!qiQCOB04DzfDDFlNy}S{$Vg9o^AY!XHMueN<{y zYPo$cJZ6f7``tmlR5h8WUGm;G*i}ff!h`}L#ypFyV7iuca!J+C-4m@7*Pmj9>m+jh zlpWbud)8j9zvQ`8-oQF#u=4!uK4kMFh>qS_pZciyq3NC(dQ{577lr-!+HD*QO_zB9 z_Rv<#qB{AAEF8Gbr7xQly%nMA%oR`a-i7nJw95F3iH&IX5hhy3CCV5y>mK4)&5aC*12 zI`{(g%MHq<(ocY5+@OK-Qn-$%!Nl%AGCgHl>e8ogTgepIKOf3)WoaOkuRJQt%MN8W z=N-kW+FLw=1^}yN@*-_c>;0N{-B!aXy#O}`%_~Nk?{e|O=JmU8@+92Q-Y6h)>@omP=9i~ zi`krLQK^!=@2BH?-R83DyFkejZkhHJqV%^} zUa&K22zwz7b*@CQV6BQ9X*RB177VCVa{Z!Lf?*c~PwS~V3K{id1TB^WZh=aMqiws5)qWylK#^SG9!tqg3-)p_o(ABJsC!0;0v36;0tC= z!zMQ_@se(*`KkTxJ~$nIx$7ez&_2EI+{4=uI~dwKD$deb5?mwLJ~ema_0Z z6A8Q$1~=tY&l5_EBZ?nAvn$3hIExWo_ZH2R)tYPjxTH5mAw#3n-*sOMVjpUrdnj1DBm4G!J+Ke}a|oQN9f?!p-TcYej+(6FNh_A? zJ3C%AOjc<8%9SPJ)U(md`W5_pzYpLEMwK<_jgeg-VXSX1Nk1oX-{yHz z-;CW!^2ds%PH{L{#12WonyeK5A=`O@s0Uc%s!@22etgSZW!K<%0(FHC+5(BxsXW@e zAvMWiO~XSkmcz%-@s{|F76uFaBJ8L5H>nq6QM-8FsX08ug_=E)r#DC>d_!6Nr+rXe zzUt30Du_d0oSfX~u>qOVR*BmrPBwL@WhF^5+dHjWRB;kB$`m8|46efLBXLkiF|*W= zg|Hd(W}ZnlJLotYZCYKoL7YsQdLXZ!F`rLqLf8n$OZOyAzK`uKcbC-n0qoH!5-rh&k-`VADETKHxrhK<5C zhF0BB4azs%j~_q_HA#fYPO0r;YTlaa-eb)Le+!IeP>4S{b8&STp|Y0if*`-A&DQ$^ z-%=i73HvEMf_V6zSEF?G>G-Eqn+|k`0=q?(^|ZcqWsuLlMF2!E*8dDAx%)}y=lyMa z$Nn0_f8YN8g<4D>8IL3)GPf#dJYU@|NZqIX$;Lco?Qj=?W6J;D@pa`T=Yh z-ybpFyFr*3^gRt!9NnbSJWs2R-S?Y4+s~J8vfrPd_&_*)HBQ{&rW(2X>P-_CZU8Y9 z-32><7|wL*K+3{ZXE5}nn~t@NNT#Bc0F6kKI4pVwLrpU@C#T-&f{Vm}0h1N3#89@d zgcx3QyS;Pb?V*XAq;3(W&rjLBazm69XX;%^n6r}0!CR2zTU1!x#TypCr`yrII%wk8 z+g)fyQ!&xIX(*>?T}HYL^>wGC2E}euj{DD_RYKK@w=yF+44367X17)GP8DCmBK!xS zE{WRfQ(WB-v>DAr!{F2-cQKHIjIUnLk^D}7XcTI#HyjSiEX)BO^GBI9NjxojYfQza zWsX@GkLc7EqtP8(UM^cq5zP~{?j~*2T^Bb={@PV)DTkrP<9&hxDwN2@hEq~8(ZiF! z3FuQH_iHyQ_s-#EmAC5~K$j_$cw{+!T>dm#8`t%CYA+->rWp09jvXY`AJQ-l%C{SJ z1c~@<5*7$`1%b}n7ivSo(1(j8k+*Gek(m^rQ!+LPvb=xA@co<|(XDK+(tb46xJ4) zcw7w<0p3=Idb_FjQ@ttoyDmF?cT4JRGrX5xl&|ViA@Lg!vRR}p#$A?0=Qe+1)Mizl zn;!zhm`B&9t0GA67GF09t_ceE(bGdJ0mbXYrUoV2iuc3c69e;!%)xNOGG*?x*@5k( zh)snvm0s&gRq^{yyeE)>hk~w8)nTN`8HJRtY0~1f`f9ue%RV4~V(K*B;jFfJY4dBb z*BGFK`9M-tpWzayiD>p_`U(29f$R|V-qEB;+_4T939BPb=XRw~8n2cGiRi`o$2qm~ zN&5N7JU{L*QGM@lO8VI)fUA0D7bPrhV(GjJ$+@=dcE5vAVyCy6r&R#4D=GyoEVOnu z8``8q`PN-pEy>xiA_@+EN?EJpY<#}BhrsUJC0afQFx7-pBeLXR9Mr+#w@!wSNR7vxHy@r`!9MFecB4O zh9jye3iSzL0@t3)OZ=OxFjjyK#KSF|zz@K}-+HaY6gW+O{T6%Zky@gD$6SW)Jq;V0 zt&LAG*YFO^+=ULohZZW*=3>7YgND-!$2}2)Mt~c>JO3j6QiPC-*ayH2xBF)2m7+}# z`@m#q{J9r~Dr^eBgrF(l^#sOjlVNFgDs5NR*Xp;V*wr~HqBx7?qBUZ8w)%vIbhhe) zt4(#1S~c$Cq7b_A%wpuah1Qn(X9#obljoY)VUoK%OiQZ#Fa|@ZvGD0_oxR=vz{>U* znC(W7HaUDTc5F!T77GswL-jj7e0#83DH2+lS-T@_^SaWfROz9btt*5zDGck${}*njAwf}3hLqKGLTeV&5(8FC+IP>s;p{L@a~RyCu)MIa zs~vA?_JQ1^2Xc&^cjDq02tT_Z0gkElR0Aa$v@VHi+5*)1(@&}gEXxP5Xon?lxE@is z9sxd|h#w2&P5uHJxWgmtVZJv5w>cl2ALzri;r57qg){6`urTu(2}EI?D?##g=!Sbh z*L*>c9xN1a3CH$u7C~u_!g81`W|xp=54oZl9CM)&V9~ATCC-Q!yfKD@vp#2EKh0(S zgt~aJ^oq-TM0IBol!w1S2j7tJ8H7;SR7yn4-H}iz&U^*zW95HrHiT!H&E|rSlnCYr z7Y1|V7xebn=TFbkH;>WIH6H>8;0?HS#b6lCke9rSsH%3AM1#2U-^*NVhXEIDSFtE^ z=jOo1>j!c__Bub(R*dHyGa)@3h?!ls1&M)d2{?W5#1|M@6|ENYYa`X=2EA_oJUw=I zjQ)K6;C!@>^i7vdf`pBOjH>Ts$97}B=lkb07<&;&?f#cy3I0p5{1=?O*#8m$C_5TE zh}&8lOWWF7I@|pRC$G2;Sm#IJfhKW@^jk=jfM1MdJP(v2fIrYTc{;e5;5gsp`}X8-!{9{S1{h+)<@?+D13s^B zq9(1Pu(Dfl#&z|~qJGuGSWDT&u{sq|huEsbJhiqMUae}K*g+R(vG7P$p6g}w*eYWn zQ7luPl1@{vX?PMK%-IBt+N7TMn~GB z!Ldy^(2Mp{fw_0;<$dgHAv1gZgyJAx%}dA?jR=NPW1K`FkoY zNDgag#YWI6-a2#&_E9NMIE~gQ+*)i<>0c)dSRUMHpg!+AL;a;^u|M1jp#0b<+#14z z+#LuQ1jCyV_GNj#lHWG3e9P@H34~n0VgP#(SBX=v|RSuOiY>L87 z#KA{JDDj2EOBX^{`a;xQxHtY1?q5^B5?up1akjEPhi1-KUsK|J9XEBAbt%^F`t0I- zjRYYKI4OB7Zq3FqJFBZwbI=RuT~J|4tA8x)(v2yB^^+TYYJS>Et`_&yge##PuQ%0I z^|X!Vtof}`UuIxPjoH8kofw4u1pT5h`Ip}d8;l>WcG^qTe>@x63s#zoJiGmDM@_h= zo;8IZR`@AJRLnBNtatipUvL^(1P_a;q8P%&voqy#R!0(bNBTlV&*W9QU?kRV1B*~I zWvI?SNo2cB<7bgVY{F_CF$7z!02Qxfw-Ew#p!8PC#! z1sRfOl`d-Y@&=)l(Sl4CS=>fVvor5lYm61C!!iF3NMocKQHUYr0%QM}a4v2>rzPfM zUO}YRDb7-NEqW+p_;e0{Zi%0C$&B3CKx6|4BW`@`AwsxE?Vu}@Jm<3%T5O&05z+Yq zkK!QF(vlN}Rm}m_J+*W4`8i~R&`P0&5!;^@S#>7qkfb9wxFv@(wN@$k%2*sEwen$a zQnWymf+#Uyv)0lQVd?L1gpS}jMQZ(NHHCKRyu zjK|Zai0|N_)5iv)67(zDBCK4Ktm#ygP|0(m5tU`*AzR&{TSeSY8W=v5^=Ic`ahxM-LBWO+uoL~wxZmgcSJMUF9q%<%>jsvh9Dnp^_e>J_V=ySx4p?SF0Y zg4ZpZt@!h>WR76~P3_YchYOak7oOzR|`t+h!BbN}?zd zq+vMTt0!duALNWDwWVIA$O=%{lWJEj;5(QD()huhFL5=6x_=1h|5ESMW&S|*oxgF# z-0GRIb ziolwI13hJ-Rl(4Rj@*^=&Zz3vD$RX8bFWvBM{niz(%?z0gWNh_vUvpBDoa>-N=P4c zbw-XEJ@txIbc<`wC883;&yE4ayVh>+N($SJ01m}fumz!#!aOg*;y4Hl{V{b;&ux3& zBEmSq2jQ7#IbVm3TPBw?2vVN z0wzj|Y6EBS(V%Pb+@OPkMvEKHW~%DZk#u|A18pZMmCrjWh%7J4Ph>vG61 zRBgJ6w^8dNRg2*=K$Wvh$t>$Q^SMaIX*UpBG)0bqcvY%*by=$EfZAy{ZOA#^tB(D( zh}T(SZgdTj?bG9u+G{Avs5Yr1x=f3k7%K|eJp^>BHK#~dsG<&+=`mM@>kQ-cAJ2k) zT+Ht5liXdc^(aMi9su~{pJUhe)!^U&qn%mV6PS%lye+Iw5F@Xv8E zdR4#?iz+R4--iiHDQmQWfNre=iofAbF~1oGTa1Ce?hId~W^kPuN(5vhNx++ZLkn?l zUA7L~{0x|qA%%%P=8+-Ck{&2$UHn#OQncFS@uUVuE39c9o~#hl)v#!$X(X*4ban2c z{buYr9!`H2;6n73n^W3Vg(!gdBV7$e#v3qubWALaUEAf@`ava{UTx%2~VVQbEE(*Q8_ zv#me9i+0=QnY)$IT+@3vP1l9Wrne+MlZNGO6|zUVG+v&lm7Xw3P*+gS6e#6mVx~(w zyuaXogGTw4!!&P3oZ1|4oc_sGEa&m3Jsqy^lzUdJ^y8RlvUjDmbC^NZ0AmO-c*&m( zSI%4P9f|s!B#073b>Eet`T@J;3qY!NrABuUaED6M^=s-Q^2oZS`jVzuA z>g&g$!Tc>`u-Q9PmKu0SLu-X(tZeZ<%7F+$j3qOOftaoXO5=4!+P!%Cx0rNU+@E~{ zxCclYb~G(Ci%o{}4PC(Bu>TyX9slm5A^2Yi$$kCq-M#Jl)a2W9L-bq5%@Pw^ zh*iuuAz`x6N_rJ1LZ7J^MU9~}RYh+EVIVP+-62u+7IC%1p@;xmmQ`dGCx$QpnIUtK z0`++;Ddz7{_R^~KDh%_yo8WM$IQhcNOALCIGC$3_PtUs?Y44@Osw;OZ()Lk=(H&Vc zXjkHt+^1@M|J%Q&?4>;%T-i%#h|Tb1u;pO5rKst8(Cv2!3U{TRXdm&>fWTJG)n*q&wQPjRzg%pS1RO9}U0*C6fhUi&f#qoV`1{U<&mWKS<$oVFW>{&*$6)r6Rx)F4W zdUL8Mm_qNk6ycFVkI5F?V+cYFUch$92|8O^-Z1JC94GU+Nuk zA#n3Z1q4<6zRiv%W5`NGk*Ym{#0E~IA6*)H-=RmfWIY%mEC0? zSih7uchi`9-WkF2@z1ev6J_N~u;d$QfSNLMgPVpHZoh9oH-8D*;EhoCr~*kJ<|-VD z_jklPveOxWZq40E!SV@0XXy+~Vfn!7nZ1GXsn~U$>#u0d*f?RL9!NMlz^qxYmz|xt zz6A&MUAV#eD%^GcP#@5}QH5e7AV`}(N2#(3xpc!7dDmgu7C3TpgX5Z|$%Vu8=&SQI zdxUk*XS-#C^-cM*O>k}WD5K81e2ayyRA)R&5>KT1QL!T!%@}fw{>BsF+-pzu>;7{g z^CCSWfH;YtJGT@+An0Ded#zM9>UEFOdR_Xq zS~!5R*{p1Whq62ynHo|n$4p7&d|bal{iGsxAY?opi3R${)Zt*8YyOU!$TWMYXF?|i zPXYr}wJp#EH;keSG5WYJ*(~oiu#GDR>C4%-HpIWr7v`W`lzQN-lb?*vpoit z8FqJ)`LC4w8fO8Fu}AYV`awF2NLMS4$f+?=KisU4P6@#+_t)5WDz@f*qE|NG0*hwO z&gv^k^kC6Fg;5>Gr`Q46C{6>3F(p0QukG6NM07rxa&?)_C*eyU(jtli>9Zh#eUb(y zt9NbC-bp0>^m?i`?$aJUyBmF`N0zQ% zvF_;vLVI{tq%Ji%u*8s2p4iBirv*uD(?t~PEz$CfxVa=@R z^HQu6-+I9w>a35kX!P)TfnJDD!)j8!%38(vWNe9vK0{k*`FS$ABZ`rdwfQe@IGDki zssfXnsa6teKXCZUTd^qhhhUZ}>GG_>F0~LG7*<*x;8e39nb-0Bka(l)%+QZ_IVy3q zcmm2uKO0p)9|HGxk*e_$mX2?->&-MXe`=Fz3FRTFfM!$_y}G?{F9jmNgD+L%R`jM1 zIP-kb=3Hlsb35Q&qo(%Ja(LwQj>~!GI|Hgq65J9^A!ibChYB3kxLn@&=#pr}BwON0Q=e5;#sF8GGGuzx6O}z%u3l?jlKF&8Y#lUA)Cs6ZiW8DgOk|q z=YBPAMsO7AoAhWgnSKae2I7%7*Xk>#AyLX-InyBO?OD_^2^nI4#;G|tBvg3C0ldO0 z*`$g(q^es4VqXH2t~0-u^m5cfK8eECh3Rb2h1kW%%^8A!+ya3OHLw$8kHorx4(vJO zAlVu$nC>D{7i?7xDg3116Y2e+)Zb4FPAdZaX}qA!WW{$d?u+sK(iIKqOE-YM zH7y^hkny24==(1;qEacfFU{W{xSXhffC&DJV&oqw`u~WAl@=HIel>KC-mLs2ggFld zsSm-03=Jd^XNDA4i$vKqJ|e|TBc19bglw{)QL${Q(xlN?E;lPumO~;4w_McND6d+R zsc2p*&uRWd`wTDszTcWKiii1mNBrF7n&LQp$2Z<}zkv=8k2s6-^+#siy_K1`5R+n( z++5VOU^LDo(kt3ok?@$3drI`<%+SWcF*`CUWqAJxl3PAq!X|q{al;8%HfgxxM#2Vb zeBS756iU|BzB>bN2NP=AX&!{uZXS;|F`LLd9F^97UTMnNks_t7EPnjZF`2ocD2*u+ z?oKP{xXrD*AKGYGkZtlnvCuazg6g16ZAF{Nu%w+LCZ+v_*`0R$NK)tOh_c#cze;o$ z)kY(eZ5Viv<5zl1XfL(#GO|2FlXL#w3T?hpj3BZ&OAl^L!7@ zy;+iJWYQYP?$(`li_!|bfn!h~k#=v-#XXyjTLd+_txOqZZETqSEp>m+O0ji7MxZ*W zSdq+yqEmafrsLErZG8&;kH2kbCwluSa<@1yU3^Q#5HmW(hYVR0E6!4ZvH;Cr<$`qf zSvqRc`Pq_9b+xrtN3qLmds9;d7HdtlR!2NV$rZPCh6>(7f7M}>C^LeM_5^b$B~mn| z#)?`E=zeo9(9?{O_ko>51~h|c?8{F=2=_-o(-eRc z9p)o51krhCmff^U2oUi#$AG2p-*wSq8DZ(i!Jmu1wzD*)#%J&r)yZTq`3e|v4>EI- z=c|^$Qhv}lEyG@!{G~@}Wbx~vxTxwKoe9zn%5_Z^H$F1?JG_Kadc(G8#|@yaf2-4< zM1bdQF$b5R!W1f`j(S>Id;CHMzfpyjYEC_95VQ*$U3y5piVy=9Rdwg7g&)%#6;U%b2W}_VVdh}qPnM4FY9zFP(5eR zWuCEFox6e;COjs$1RV}IbpE0EV;}5IP}Oq|zcb*77PEDIZU{;@_;8*22{~JRvG~1t zc+ln^I+)Q*+Ha>(@=ra&L&a-kD;l$WEN;YL0q^GE8+})U_A_StHjX_gO{)N>tx4&F zRK?99!6JqktfeS-IsD@74yuq*aFJoV{5&K(W`6Oa2Qy0O5JG>O`zZ-p7vBGh!MxS;}}h6(96Wp`dci3DY?|B@1p8fVsDf$|0S zfE{WL5g3<9&{~yygYyR?jK!>;eZ2L#tpL2)H#89*b zycE?VViXbH7M}m33{#tI69PUPD=r)EVPTBku={Qh{ zKi*pht1jJ+yRhVE)1=Y()iS9j`FesMo$bjLSqPMF-i<42Hxl6%y7{#vw5YT(C}x0? z$rJU7fFmoiR&%b|Y*pG?7O&+Jb#Z%S8&%o~fc?S9c`Dwdnc4BJC7njo7?3bp#Yonz zPC>y`DVK~nzN^n}jB5RhE4N>LzhCZD#WQseohYXvqp5^%Ns!q^B z&8zQN(jgPS(2ty~g2t9!x9;Dao~lYVujG-QEq{vZp<1Nlp;oj#kFVsBnJssU^p-4% zKF_A?5sRmA>d*~^og-I95z$>T*K*33TGBPzs{OMoV2i+(P6K|95UwSj$Zn<@Rt(g%|iY z$SkSjYVJ)I<@S(kMQ6md{HxAa8S`^lXGV?ktLX!ngTVI~%WW+p#A#XTWaFWeBAl%U z&rVhve#Yse*h4BC4nrq7A1n>Rlf^ErbOceJC`o#fyCu@H;y)`E#a#)w)3eg^{Hw&E7);N5*6V+z%olvLj zp^aJ4`h*4L4ij)K+uYvdpil(Z{EO@u{BcMI&}5{ephilI%zCkBhBMCvOQT#zp|!18 zuNl=idd81|{FpGkt%ty=$fnZnWXxem!t4x{ zat@68CPmac(xYaOIeF}@O1j8O?2jbR!KkMSuix;L8x?m01}|bS2=&gsjg^t2O|+0{ zlzfu5r5_l4)py8uPb5~NHPG>!lYVynw;;T-gk1Pl6PQ39Mwgd2O+iHDB397H)2grN zHwbd>8i%GY>Pfy7;y5X7AN>qGLZVH>N_ZuJZ-`z9UA> zfyb$nbmPqxyF2F;UW}7`Cu>SS%0W6h^Wq5e{PWAjxlh=#Fq+6SiPa-L*551SZKX&w zc9TkPv4eao?kqomkZ#X%tA{`UIvf|_=Y7p~mHZKqO>i_;q4PrwVtUDTk?M7NCssa?Y4uxYrsXj!+k@`Cxl;&{NLs*6!R<6k9$Bq z%grLhxJ#G_j~ytJpiND8neLfvD0+xu>wa$-%5v;4;RYYM66PUab)c9ruUm%d{^s{# zTBBY??@^foRv9H}iEf{w_J%rV<%T1wv^`)Jm#snLTIifjgRkX``x2wV(D6(=VTLL4 zI-o}&5WuwBl~(XSLIn5~{cGWorl#z+=(vXuBXC#lp}SdW=_)~8Z(Vv!#3h2@pdA3d z{cIPYK@Ojc9(ph=H3T7;aY>(S3~iuIn05Puh^32WObj%hVN(Y{Ty?n?Cm#!kGNZFa zW6Ybz!tq|@erhtMo4xAus|H8V_c+XfE5mu|lYe|{$V3mKnb1~fqoFim;&_ZHN_=?t zysQwC4qO}rTi}k8_f=R&i27RdBB)@bTeV9Wcd}Rysvod}7I%ujwYbTI*cN7Kbp_hO z=eU521!#cx$0O@k9b$;pnCTRtLIzv){nVW6Ux1<0@te6`S5%Ew3{Z^9=lbL5$NFvd4eUtK?%zgmB;_I&p`)YtpN`2Im(?jPN<(7Ua_ZWJRF(CChv`(gHfWodK%+joy>8Vaa;H1w zIJ?!kA|x7V;4U1BNr(UrhfvjPii7YENLIm`LtnL9Sx z5E9TYaILoB2nSwDe|BVmrpLT43*dJ8;T@1l zJE)4LEzIE{IN}+Nvpo3=ZtV!U#D;rB@9OXYw^4QH+(52&pQEcZq&~u9bTg63ikW9! z=!_RjN2xO=F+bk>fSPhsjQA;)%M1My#34T`I7tUf>Q_L>DRa=>Eo(sapm>}}LUsN% zVw!C~a)xcca`G#g*Xqo>_uCJTz>LoWGSKOwp-tv`yvfqw{17t`9Z}U4o+q2JGP^&9 z(m}|d13XhYSnEm$_8vH-Lq$A^>oWUz1)bnv|AVn_0FwM$vYu&8+qUg$+qP}nwrykD zwmIF?wr$()X@33oz1@B9zi+?Th^nZnsES)rb@O*K^JL~ZH|pRRk$i0+ohh?Il)y&~ zQaq{}9YxPt5~_2|+r#{k#~SUhO6yFq)uBGtYMMg4h1qddg!`TGHocYROyNFJtYjNe z3oezNpq6%TP5V1g(?^5DMeKV|i6vdBq)aGJ)BRv;K(EL0_q7$h@s?BV$)w31*c(jd z{@hDGl3QdXxS=#?0y3KmPd4JL(q(>0ikTk6nt98ptq$6_M|qrPi)N>HY>wKFbnCKY z%0`~`9p)MDESQJ#A`_>@iL7qOCmCJ(p^>f+zqaMuDRk!z01Nd2A_W^D%~M73jTqC* zKu8u$$r({vP~TE8rPk?8RSjlRvG*BLF}ye~Su%s~rivmjg2F z24dhh6-1EQF(c>Z1E8DWY)Jw#9U#wR<@6J)3hjA&2qN$X%piJ4s={|>d-|Gzl~RNu z##iR(m;9TN3|zh+>HgTI&82iR>$YVoOq$a(2%l*2mNP(AsV=lR^>=tIP-R9Tw!BYnZROx`PN*JiNH>8bG}&@h0_v$yOTk#@1;Mh;-={ZU7e@JE(~@@y0AuETvsqQV@7hbKe2wiWk@QvV=Kz`%@$rN z_0Hadkl?7oEdp5eaaMqBm;#Xj^`fxNO^GQ9S3|Fb#%{lN;1b`~yxLGEcy8~!cz{!! z=7tS!I)Qq%w(t9sTSMWNhoV#f=l5+a{a=}--?S!rA0w}QF!_Eq>V4NbmYKV&^OndM z4WiLbqeC5+P@g_!_rs01AY6HwF7)$~%Ok^(NPD9I@fn5I?f$(rcOQjP+z?_|V0DiN zb}l0fy*el9E3Q7fVRKw$EIlb&T0fG~fDJZL7Qn8*a5{)vUblM)*)NTLf1ll$ zpQ^(0pkSTol`|t~`Y4wzl;%NRn>689mpQrW=SJ*rB;7}w zVHB?&sVa2%-q@ANA~v)FXb`?Nz8M1rHKiZB4xC9<{Q3T!XaS#fEk=sXI4IFMnlRqG+yaFw< zF{}7tcMjV04!-_FFD8(FtuOZx+|CjF@-xl6-{qSFF!r7L3yD()=*Ss6fT?lDhy(h$ zt#%F575$U(3-e2LsJd>ksuUZZ%=c}2dWvu8f!V%>z3gajZ!Dlk zm=0|(wKY`c?r$|pX6XVo6padb9{EH}px)jIsdHoqG^(XH(7}r^bRa8BC(%M+wtcB? z6G2%tui|Tx6C3*#RFgNZi9emm*v~txI}~xV4C`Ns)qEoczZ>j*r zqQCa5k90Gntl?EX!{iWh=1t$~jVoXjs&*jKu0Ay`^k)hC^v_y0xU~brMZ6PPcmt5$ z@_h`f#qnI$6BD(`#IR0PrITIV^~O{uo=)+Bi$oHA$G* zH0a^PRoeYD3jU_k%!rTFh)v#@cq`P3_y=6D(M~GBud;4 zCk$LuxPgJ5=8OEDlnU!R^4QDM4jGni}~C zy;t2E%Qy;A^bz_5HSb5pq{x{g59U!ReE?6ULOw58DJcJy;H?g*ofr(X7+8wF;*3{rx>j&27Syl6A~{|w{pHb zeFgu0E>OC81~6a9(2F13r7NZDGdQxR8T68&t`-BK zE>ZV0*0Ba9HkF_(AwfAds-r=|dA&p`G&B_zn5f9Zfrz9n#Rvso`x%u~SwE4SzYj!G zVQ0@jrLwbYP=awX$21Aq!I%M{x?|C`narFWhp4n;=>Sj!0_J!k7|A0;N4!+z%Oqlk z1>l=MHhw3bi1vT}1!}zR=6JOIYSm==qEN#7_fVsht?7SFCj=*2+Ro}B4}HR=D%%)F z?eHy=I#Qx(vvx)@Fc3?MT_@D))w@oOCRR5zRw7614#?(-nC?RH`r(bb{Zzn+VV0bm zJ93!(bfrDH;^p=IZkCH73f*GR8nDKoBo|!}($3^s*hV$c45Zu>6QCV(JhBW=3(Tpf z=4PT6@|s1Uz+U=zJXil3K(N6;ePhAJhCIo`%XDJYW@x#7Za);~`ANTvi$N4(Fy!K- z?CQ3KeEK64F0@ykv$-0oWCWhYI-5ZC1pDqui@B|+LVJmU`WJ=&C|{I_))TlREOc4* zSd%N=pJ_5$G5d^3XK+yj2UZasg2) zXMLtMp<5XWWfh-o@ywb*nCnGdK{&S{YI54Wh2|h}yZ})+NCM;~i9H@1GMCgYf`d5n zwOR(*EEkE4-V#R2+Rc>@cAEho+GAS2L!tzisLl${42Y=A7v}h;#@71_Gh2MV=hPr0_a% z0!={Fcv5^GwuEU^5rD|sP;+y<%5o9;#m>ssbtVR2g<420(I-@fSqfBVMv z?`>61-^q;M(b3r2z{=QxSjyH=-%99fpvb}8z}d;%_8$$J$qJg1Sp3KzlO_!nCn|g8 zzg8skdHNsfgkf8A7PWs;YBz_S$S%!hWQ@G>guCgS--P!!Ui9#%GQ#Jh?s!U-4)7ozR?i>JXHU$| zg0^vuti{!=N|kWorZNFX`dJgdphgic#(8sOBHQdBkY}Qzp3V%T{DFb{nGPgS;QwnH9B9;-Xhy{? z(QVwtzkn9I)vHEmjY!T3ifk1l5B?%%TgP#;CqG-?16lTz;S_mHOzu#MY0w}XuF{lk z*dt`2?&plYn(B>FFXo+fd&CS3q^hquSLVEn6TMAZ6e*WC{Q2e&U7l|)*W;^4l~|Q= zt+yFlLVqPz!I40}NHv zE2t1meCuGH%<`5iJ(~8ji#VD{?uhP%F(TnG#uRZW-V}1=N%ev&+Gd4v!0(f`2Ar-Y z)GO6eYj7S{T_vxV?5^%l6TF{ygS_9e2DXT>9caP~xq*~oE<5KkngGtsv)sdCC zaQH#kSL%c*gLj6tV)zE6SGq|0iX*DPV|I`byc9kn_tNQkPU%y<`rj zMC}lD<93=Oj+D6Y2GNMZb|m$^)RVdi`&0*}mxNy0BW#0iq!GGN2BGx5I0LS>I|4op z(6^xWULBr=QRpbxIJDK~?h;K#>LwQI4N<8V?%3>9I5l+e*yG zFOZTIM0c3(q?y9f7qDHKX|%zsUF%2zN9jDa7%AK*qrI5@z~IruFP+IJy7!s~TE%V3 z_PSSxXlr!FU|Za>G_JL>DD3KVZ7u&}6VWbwWmSg?5;MabycEB)JT(eK8wg`^wvw!Q zH5h24_E$2cuib&9>Ue&@%Cly}6YZN-oO_ei5#33VvqV%L*~ZehqMe;)m;$9)$HBsM zfJ96Hk8GJyWwQ0$iiGjwhxGgQX$sN8ij%XJzW`pxqgwW=79hgMOMnC|0Q@ed%Y~=_ z?OnjUB|5rS+R$Q-p)vvM(eFS+Qr{_w$?#Y;0Iknw3u(+wA=2?gPyl~NyYa3me{-Su zhH#8;01jEm%r#5g5oy-f&F>VA5TE_9=a0aO4!|gJpu470WIrfGo~v}HkF91m6qEG2 zK4j=7C?wWUMG$kYbIp^+@)<#ArZ$3k^EQxraLk0qav9TynuE7T79%MsBxl3|nRn?L zD&8kt6*RJB6*a7=5c57wp!pg)p6O?WHQarI{o9@3a32zQ3FH8cK@P!DZ?CPN_LtmC6U4F zlv8T2?sau&+(i@EL6+tvP^&=|aq3@QgL4 zOu6S3wSWeYtgCnKqg*H4ifIQlR4hd^n{F+3>h3;u_q~qw-Sh;4dYtp^VYymX12$`? z;V2_NiRt82RC=yC+aG?=t&a81!gso$hQUb)LM2D4Z{)S zI1S9f020mSm(Dn$&Rlj0UX}H@ zv={G+fFC>Sad0~8yB%62V(NB4Z|b%6%Co8j!>D(VyAvjFBP%gB+`b*&KnJ zU8s}&F+?iFKE(AT913mq;57|)q?ZrA&8YD3Hw*$yhkm;p5G6PNiO3VdFlnH-&U#JH zEX+y>hB(4$R<6k|pt0?$?8l@zeWk&1Y5tlbgs3540F>A@@rfvY;KdnVncEh@N6Mfi zY)8tFRY~Z?Qw!{@{sE~vQy)0&fKsJpj?yR`Yj+H5SDO1PBId3~d!yjh>FcI#Ug|^M z7-%>aeyQhL8Zmj1!O0D7A2pZE-$>+-6m<#`QX8(n)Fg>}l404xFmPR~at%$(h$hYD zoTzbxo`O{S{E}s8Mv6WviXMP}(YPZoL11xfd>bggPx;#&pFd;*#Yx%TtN1cp)MuHf z+Z*5CG_AFPwk624V9@&aL0;=@Ql=2h6aJoqWx|hPQQzdF{e7|fe(m){0==hk_!$ou zI|p_?kzdO9&d^GBS1u+$>JE-6Ov*o{mu@MF-?$r9V>i%;>>Fo~U`ac2hD*X}-gx*v z1&;@ey`rA0qNcD9-5;3_K&jg|qvn@m^+t?8(GTF0l#|({Zwp^5Ywik@bW9mN+5`MU zJ#_Ju|jtsq{tv)xA zY$5SnHgHj}c%qlQG72VS_(OSv;H~1GLUAegygT3T-J{<#h}))pk$FjfRQ+Kr%`2ZiI)@$96Nivh82#K@t>ze^H?R8wHii6Pxy z0o#T(lh=V>ZD6EXf0U}sG~nQ1dFI`bx;vivBkYSVkxXn?yx1aGxbUiNBawMGad;6? zm{zp?xqAoogt=I2H0g@826=7z^DmTTLB11byYvAO;ir|O0xmNN3Ec0w%yHO({-%q(go%?_X{LP?=E1uXoQgrEGOfL1?~ zI%uPHC23dn-RC@UPs;mxq6cFr{UrgG@e3ONEL^SoxFm%kE^LBhe_D6+Ia+u0J=)BC zf8FB!0J$dYg33jb2SxfmkB|8qeN&De!%r5|@H@GiqReK(YEpnXC;-v~*o<#JmYuze zW}p-K=9?0=*fZyYTE7A}?QR6}m_vMPK!r~y*6%My)d;x4R?-=~MMLC_02KejX9q6= z4sUB4AD0+H4ulSYz4;6mL8uaD07eXFvpy*i5X@dmx--+9`ur@rcJ5<L#s%nq3MRi4Dpr;#28}dl36M{MkVs4+Fm3Pjo5qSV)h}i(2^$Ty|<7N z>*LiBzFKH30D!$@n^3B@HYI_V1?yM(G$2Ml{oZ}?frfPU+{i|dHQOP^M0N2#NN_$+ zs*E=MXUOd=$Z2F4jSA^XIW=?KN=w6{_vJ4f(ZYhLxvFtPozPJv9k%7+z!Zj+_0|HC zMU0(8`8c`Sa=%e$|Mu2+CT22Ifbac@7Vn*he`|6Bl81j`44IRcTu8aw_Y%;I$Hnyd zdWz~I!tkWuGZx4Yjof(?jM;exFlUsrj5qO=@2F;56&^gM9D^ZUQ!6TMMUw19zslEu zwB^^D&nG96Y+Qwbvgk?Zmkn9%d{+V;DGKmBE(yBWX6H#wbaAm&O1U^ zS4YS7j2!1LDC6|>cfdQa`}_^satOz6vc$BfFIG07LoU^IhVMS_u+N=|QCJao0{F>p z-^UkM)ODJW9#9*o;?LPCRV1y~k9B`&U)jbTdvuxG&2%!n_Z&udT=0mb@e;tZ$_l3bj6d0K2;Ya!&)q`A${SmdG_*4WfjubB)Mn+vaLV+)L5$yD zYSTGxpVok&fJDG9iS8#oMN{vQneO|W{Y_xL2Hhb%YhQJgq7j~X7?bcA|B||C?R=Eo z!z;=sSeKiw4mM$Qm>|aIP3nw36Tbh6Eml?hL#&PlR5xf9^vQGN6J8op1dpLfwFg}p zlqYx$610Zf?=vCbB_^~~(e4IMic7C}X(L6~AjDp^;|=d$`=!gd%iwCi5E9<6Y~z0! zX8p$qprEadiMgq>gZ_V~n$d~YUqqqsL#BE6t9ufXIUrs@DCTfGg^-Yh5Ms(wD1xAf zTX8g52V!jr9TlWLl+whcUDv?Rc~JmYs3haeG*UnV;4bI=;__i?OSk)bF3=c9;qTdP zeW1exJwD+;Q3yAw9j_42Zj9nuvs%qGF=6I@($2Ue(a9QGRMZTd4ZAlxbT5W~7(alP1u<^YY!c3B7QV z@jm$vn34XnA6Gh1I)NBgTmgmR=O1PKp#dT*mYDPRZ=}~X3B8}H*e_;;BHlr$FO}Eq zJ9oWk0y#h;N1~ho724x~d)A4Z-{V%F6#e5?Z^(`GGC}sYp5%DKnnB+i-NWxwL-CuF+^JWNl`t@VbXZ{K3#aIX+h9-{T*+t(b0BM&MymW9AA*{p^&-9 zWpWQ?*z(Yw!y%AoeoYS|E!(3IlLksr@?Z9Hqlig?Q4|cGe;0rg#FC}tXTmTNfpE}; z$sfUYEG@hLHUb$(K{A{R%~%6MQN|Bu949`f#H6YC*E(p3lBBKcx z-~Bsd6^QsKzB0)$FteBf*b3i7CN4hccSa-&lfQz4qHm>eC|_X!_E#?=`M(bZ{$cvU zZpMbr|4omp`s9mrgz@>4=Fk3~8Y7q$G{T@?oE0<(I91_t+U}xYlT{c&6}zPAE8ikT z3DP!l#>}i!A(eGT+@;fWdK#(~CTkwjs?*i4SJVBuNB2$6!bCRmcm6AnpHHvnN8G<| zuh4YCYC%5}Zo;BO1>L0hQ8p>}tRVx~O89!${_NXhT!HUoGj0}bLvL2)qRNt|g*q~B z7U&U7E+8Ixy1U`QT^&W@ZSRN|`_Ko$-Mk^^c%`YzhF(KY9l5))1jSyz$&>mWJHZzHt0Jje%BQFxEV}C00{|qo5_Hz7c!FlJ|T(JD^0*yjkDm zL}4S%JU(mBV|3G2jVWU>DX413;d+h0C3{g3v|U8cUj`tZL37Sf@1d*jpwt4^B)`bK zZdlwnPB6jfc7rIKsldW81$C$a9BukX%=V}yPnaBz|i6(h>S)+Bn44@i8RtBZf0XetH&kAb?iAL zD%Ge{>Jo3sy2hgrD?15PM}X_)(6$LV`&t*D`IP)m}bzM)+x-xRJ zavhA)>hu2cD;LUTvN38FEtB94ee|~lIvk~3MBPzmTsN|7V}Kzi!h&za#NyY zX^0BnB+lfBuW!oR#8G&S#Er2bCVtA@5FI`Q+a-e?G)LhzW_chWN-ZQmjtR

eWu-UOPu^G}|k=o=;ffg>8|Z*qev7qS&oqA7%Z{4Ezb!t$f3& z^NuT8CSNp`VHScyikB1YO{BgaBVJR&>dNIEEBwYkfOkWN;(I8CJ|vIfD}STN z{097)R9iC@6($s$#dsb*4BXBx7 zb{6S2O}QUk>upEfij9C2tjqWy7%%V@Xfpe)vo6}PG+hmuY1Tc}peynUJLLmm)8pshG zb}HWl^|sOPtYk)CD-7{L+l(=F zOp}fX8)|n{JDa&9uI!*@jh^^9qP&SbZ(xxDhR)y|bjnn|K3MeR3gl6xcvh9uqzb#K zYkVjnK$;lUky~??mcqN-)d5~mk{wXhrf^<)!Jjqc zG~hX0P_@KvOKwV=X9H&KR3GnP3U)DfqafBt$e10}iuVRFBXx@uBQ)sn0J%%c<;R+! zQz;ETTVa+ma>+VF%U43w?_F6s0=x@N2(oisjA7LUOM<$|6iE|$WcO67W|KY8JUV_# zg7P9K3Yo-c*;EmbsqT!M4(WT`%9uk+s9Em-yB0bE{B%F4X<8fT!%4??vezaJ(wJhj zfOb%wKfkY3RU}7^FRq`UEbB-#A-%7)NJQwQd1As=!$u#~2vQ*CE~qp`u=_kL<`{OL zk>753UqJVx1-4~+d@(pnX-i zV4&=eRWbJ)9YEGMV53poXpv$vd@^yd05z$$@i5J7%>gYKBx?mR2qGv&BPn!tE-_aW zg*C!Z&!B zH>3J16dTJC(@M0*kIc}Jn}jf=f*agba|!HVm|^@+7A?V>Woo!$SJko*Jv1mu>;d}z z^vF{3u5Mvo_94`4kq2&R2`32oyoWc2lJco3`Ls0Ew4E7*AdiMbn^LCV%7%mU)hr4S3UVJjDLUoIKRQ)gm?^{1Z}OYzd$1?a~tEY ztjXmIM*2_qC|OC{7V%430T?RsY?ZLN$w!bkDOQ0}wiq69){Kdu3SqW?NMC))S}zq^ zu)w!>E1!;OrXO!RmT?m&PA;YKUjJy5-Seu=@o;m4*Vp$0OipBl4~Ub)1xBdWkZ47=UkJd$`Z}O8ZbpGN$i_WtY^00`S8=EHG#Ff{&MU1L(^wYjTchB zMTK%1LZ(eLLP($0UR2JVLaL|C2~IFbWirNjp|^=Fl48~Sp9zNOCZ@t&;;^avfN(NpNfq}~VYA{q%yjHo4D>JB>XEv(~Z!`1~SoY=9v zTq;hrjObE_h)cmHXLJ>LC_&XQ2BgGfV}e#v}ZF}iF97bG`Nog&O+SA`2zsn%bbB309}I$ zYi;vW$k@fC^muYBL?XB#CBuhC&^H)F4E&vw(5Q^PF{7~}(b&lF4^%DQzL0(BVk?lM zTHXTo4?Ps|dRICEiux#y77_RF8?5!1D-*h5UY&gRY`WO|V`xxB{f{DHzBwvt1W==r zdfAUyd({^*>Y7lObr;_fO zxDDw7X^dO`n!PLqHZ`by0h#BJ-@bAFPs{yJQ~Ylj^M5zWsxO_WFHG}8hH>OK{Q)9` zSRP94d{AM(q-2x0yhK@aNMv!qGA5@~2tB;X?l{Pf?DM5Y*QK`{mGA? zjx;gwnR~#Nep12dFk<^@-U{`&`P1Z}Z3T2~m8^J&7y}GaMElsTXg|GqfF3>E#HG=j zMt;6hfbfjHSQ&pN9(AT8q$FLKXo`N(WNHDY!K6;JrHZCO&ISBdX`g8sXvIf?|8 zX$-W^ut!FhBxY|+R49o44IgWHt}$1BuE|6|kvn1OR#zhyrw}4H*~cpmFk%K(CTGYc zNkJ8L$eS;UYDa=ZHWZy`rO`!w0oIcgZnK&xC|93#nHvfb^n1xgxf{$LB`H1ao+OGb zKG_}>N-RHSqL(RBdlc7J-Z$Gaay`wEGJ_u-lo88{`aQ*+T~+x(H5j?Q{uRA~>2R+} zB+{wM2m?$->unwg8-GaFrG%ZmoHEceOj{W21)Mi2lAfT)EQuNVo+Do%nHPuq7Ttt7 z%^6J5Yo64dH671tOUrA7I2hL@HKZq;S#Ejxt;*m-l*pPj?=i`=E~FAXAb#QH+a}-% z#3u^pFlg%p{hGiIp>05T$RiE*V7bPXtkz(G<+^E}Risi6F!R~Mbf(Qz*<@2&F#vDr zaL#!8!&ughWxjA(o9xtK{BzzYwm_z2t*c>2jI)c0-xo8ahnEqZ&K;8uF*!Hg0?Gd* z=eJK`FkAr>7$_i$;kq3Ks5NNJkNBnw|1f-&Ys56c9Y@tdM3VTTuXOCbWqye9va6+ZSeF0eh} zYb^ct&4lQTfNZ3M3(9?{;s><(zq%hza7zcxlZ+`F8J*>%4wq8s$cC6Z=F@ zhbvdv;n$%vEI$B~B)Q&LkTse!8Vt};7Szv2@YB!_Ztp@JA>rc(#R1`EZcIdE+JiI% zC2!hgYt+~@%xU?;ir+g92W`*j z3`@S;I6@2rO28zqj&SWO^CvA5MeNEhBF+8-U0O0Q1Co=I^WvPl%#}UFDMBVl z5iXV@d|`QTa$>iw;m$^}6JeuW zjr;{)S2TfK0Q%xgHvONSJb#NA|LOmg{U=k;R?&1tQbylMEY4<1*9mJh&(qo`G#9{X zYRs)#*PtEHnO;PV0G~6G`ca%tpKgb6<@)xc^SQY58lTo*S$*sv5w7bG+8YLKYU`8{ zNBVlvgaDu7icvyf;N&%42z2L4(rR<*Jd48X8Jnw zN>!R$%MZ@~Xu9jH?$2Se&I|ZcW>!26BJP?H7og0hT(S`nXh6{sR36O^7%v=31T+eL z)~BeC)15v>1m#(LN>OEwYFG?TE0_z)MrT%3SkMBBjvCd6!uD+03Jz#!s#Y~b1jf>S z&Rz5&8rbLj5!Y;(Hx|UY(2aw~W(8!3q3D}LRE%XX(@h5TnP@PhDoLVQx;6|r^+Bvs zaR55cR%Db9hZ<<|I%dDkone+8Sq7dqPOMnGoHk~-R*#a8w$c)`>4U`k+o?2|E>Sd4 zZ0ZVT{95pY$qKJ54K}3JB!(WcES>F+x56oJBRg))tMJ^#Qc(2rVcd5add=Us6vpBNkIg9b#ulk%!XBU zV^fH1uY(rGIAiFew|z#MM!qsVv%ZNb#why9%9In4Kj-hDYtMdirWLFzn~de!nnH(V zv0>I3;X#N)bo1$dFzqo(tzmvqNUKraAz~?)OSv42MeM!OYu;2VKn2-s7#fucX`|l~ zplxtG1Pgk#(;V=`P_PZ`MV{Bt4$a7;aLvG@KQo%E=;7ZO&Ws-r@XL+AhnPn>PAKc7 zQ_iQ4mXa-a4)QS>cJzt_j;AjuVCp8g^|dIV=DI0>v-f_|w5YWAX61lNBjZEZax3aV znher(j)f+a9_s8n#|u=kj0(unR1P-*L7`{F28xv054|#DMh}q=@rs@-fbyf(2+52L zN>hn3v!I~%jfOV=j(@xLOsl$Jv-+yR5{3pX)$rIdDarl7(C3)})P`QoHN|y<<2n;` zJ0UrF=Zv}d=F(Uj}~Yv9(@1pqUSRa5_bB*AvQ|Z-6YZ*N%p(U z<;Bpqr9iEBe^LFF!t{1UnRtaH-9=@p35fMQJ~1^&)(2D|^&z?m z855r&diVS6}jmt2)A7LZDiv;&Ys6@W5P{JHY!!n7W zvj3(2{1R9Y=TJ|{^2DK&be*ZaMiRHw>WVI^701fC) zAp1?8?oiU%Faj?Qhou6S^d11_7@tEK-XQ~%q!!7hha-Im^>NcRF7OH7s{IO7arZQ{ zE8n?2><7*!*lH}~usWPWZ}2&M+)VQo7C!AWJSQc>8g_r-P`N&uybK5)p$5_o;+58Q z-Ux2l<3i|hxqqur*qAfHq=)?GDchq}ShV#m6&w|mi~ar~`EO_S=fb~<}66U>5i7$H#m~wR;L~4yHL2R&;L*u7-SPdHxLS&Iy76q$2j#Pe)$WulRiCICG*t+ zeehM8`!{**KRL{Q{8WCEFLXu3+`-XF(b?c1Z~wg?c0lD!21y?NLq?O$STk3NzmrHM zsCgQS5I+nxDH0iyU;KKjzS24GJmG?{D`08|N-v+Egy92lBku)fnAM<}tELA_U`)xKYb=pq|hejMCT1-rg0Edt6(*E9l9WCKI1a=@c99swp2t6Tx zFHy`8Hb#iXS(8c>F~({`NV@F4w0lu5X;MH6I$&|h*qfx{~DJ*h5e|61t1QP}tZEIcjC%!Fa)omJTfpX%aI+OD*Y(l|xc0$1Zip;4rx; zV=qI!5tSuXG7h?jLR)pBEx!B15HCoVycD&Z2dlqN*MFQDb!|yi0j~JciNC!>){~ zQQgmZvc}0l$XB0VIWdg&ShDTbTkArryp3x)T8%ulR;Z?6APx{JZyUm=LC-ACkFm`6 z(x7zm5ULIU-xGi*V6x|eF~CN`PUM%`!4S;Uv_J>b#&OT9IT=jx5#nydC4=0htcDme zDUH*Hk-`Jsa>&Z<7zJ{K4AZE1BVW%zk&MZ^lHyj8mWmk|Pq8WwHROz0Kwj-AFqvR)H2gDN*6dzVk>R3@_CV zw3Z@6s^73xW)XY->AFwUlk^4Q=hXE;ckW=|RcZFchyOM0vqBW{2l*QR#v^SZNnT6j zZv|?ZO1-C_wLWVuYORQryj29JA; zS4BsxfVl@X!W{!2GkG9fL4}58Srv{$-GYngg>JuHz!7ZPQbfIQr4@6ZC4T$`;Vr@t zD#-uJ8A!kSM*gA&^6yWi|F}&59^*Rx{qn3z{(JYxrzg!X2b#uGd>&O0e=0k_2*N?3 zYXV{v={ONL{rW~z_FtFj7kSSJZ?s);LL@W&aND7blR8rlvkAb48RwJZlOHA~t~RfC zOD%ZcOzhYEV&s9%qns0&ste5U!^MFWYn`Od()5RwIz6%@Ek+Pn`s79unJY-$7n-Uf z&eUYvtd)f7h7zG_hDiFC!psCg#q&0c=GHKOik~$$>$Fw*k z;G)HS$IR)Cu72HH|JjeeauX;U6IgZ_IfxFCE_bGPAU25$!j8Etsl0Rk@R`$jXuHo8 z3Hhj-rTR$Gq(x)4Tu6;6rHQhoCvL4Q+h0Y+@Zdt=KTb0~wj7-(Z9G%J+aQu05@k6JHeCC|YRFWGdDCV}ja;-yl^9<`>f=AwOqML1a~* z9@cQYb?!+Fmkf}9VQrL8$uyq8k(r8)#;##xG9lJ-B)Fg@15&To(@xgk9SP*bkHlxiy8I*wJQylh(+9X~H-Is!g&C!q*eIYuhl&fS&|w)dAzXBdGJ&Mp$+8D| zZaD<+RtjI90QT{R0YLk6_dm=GfCg>7;$ zlyLsNYf@MfLH<}ott5)t2CXiQos zFLt^`%ygB2Vy^I$W3J_Rt4olRn~Gh}AW(`F@LsUN{d$sR%bU&3;rsD=2KCL+4c`zv zlI%D>9-)U&R3;>d1Vdd5b{DeR!HXDm44Vq*u?`wziLLsFUEp4El;*S0;I~D#TgG0s zBXYZS{o|Hy0A?LVNS)V4c_CFwyYj-E#)4SQq9yaf`Y2Yhk7yHSdos~|fImZG5_3~~o<@jTOH@Mc7`*xn-aO5F zyFT-|LBsm(NbWkL^oB-Nd31djBaYebhIGXhsJyn~`SQ6_4>{fqIjRp#Vb|~+Qi}Mdz!Zsw= zz?5L%F{c{;Cv3Q8ab>dsHp)z`DEKHf%e9sT(aE6$az?A}3P`Lm(~W$8Jr=;d8#?dm_cmv>2673NqAOenze z=&QW`?TQAu5~LzFLJvaJ zaBU3mQFtl5z?4XQDBWNPaH4y)McRpX#$(3o5Nx@hVoOYOL&-P+gqS1cQ~J;~1roGH zVzi46?FaI@w-MJ0Y7BuAg*3;D%?<_OGsB3)c|^s3A{UoAOLP8scn`!5?MFa|^cTvq z#%bYG3m3UO9(sH@LyK9-LSnlVcm#5^NRs9BXFtRN9kBY2mPO|@b7K#IH{B{=0W06) zl|s#cIYcreZ5p3j>@Ly@35wr-q8z5f9=R42IsII=->1stLo@Q%VooDvg@*K(H@*5g zUPS&cM~k4oqp`S+qp^*nxzm^0mg3h8ppEHQ@cXyQ=YKV-6)FB*$KCa{POe2^EHr{J zOxcVd)s3Mzs8m`iV?MSp=qV59blW9$+$P+2;PZDRUD~sr*CQUr&EDiCSfH@wuHez+ z`d5p(r;I7D@8>nbZ&DVhT6qe+accH;<}q$8Nzz|d1twqW?UV%FMP4Y@NQ`3(+5*i8 zP9*yIMP7frrneG3M9 zf>GsjA!O#Bifr5np-H~9lR(>#9vhE6W-r`EjjeQ_wdWp+rt{{L5t5t(Ho|4O24@}4 z_^=_CkbI`3;~sXTnnsv=^b3J}`;IYyvb1gM>#J9{$l#Zd*W!;meMn&yXO7x`Epx_Y zm-1wlu~@Ii_7D}>%tzlXW;zQT=uQXSG@t$<#6-W*^vy7Vr2TCpnix@7!_|aNXEnN<-m?Oq;DpN*x6f>w za1Wa5entFEDtA0SD%iZv#3{wl-S`0{{i3a9cmgNW`!TH{J*~{@|5f%CKy@uk*8~af zt_d34U4y&3y9IZ5cXxLQ?(XjH5?q3Z0KxK~y!-CUyWG6{<)5lkhbox0HnV&7^zNBn zjc|?X!Y=63(Vg>#&Wx%=LUr5{i@~OdzT#?P8xu#P*I_?Jl7xM4dq)4vi}3Wj_c=XI zSbc)@Q2Et4=(nBDU{aD(F&*%Ix!53_^0`+nOFk)}*34#b0Egffld|t_RV91}S0m)0 zap{cQDWzW$geKzYMcDZDAw480!1e1!1Onpv9fK9Ov~sfi!~OeXb(FW)wKx335nNY! za6*~K{k~=pw`~3z!Uq%?MMzSl#s%rZM{gzB7nB*A83XIGyNbi|H8X>a5i?}Rs+z^; z2iXrmK4|eDOu@{MdS+?@(!-Ar4P4?H_yjTEMqm7`rbV4P275(-#TW##v#Dt14Yn9UB-Sg3`WmL0+H~N;iC`Mg%pBl?1AAOfZ&e; z*G=dR>=h_Mz@i;lrGpIOQwezI=S=R8#);d*;G8I(39ZZGIpWU)y?qew(t!j23B9fD z?Uo?-Gx3}6r8u1fUy!u)7LthD2(}boE#uhO&mKBau8W8`XV7vO>zb^ZVWiH-DOjl2 zf~^o1CYVU8eBdmpAB=T%i(=y}!@3N%G-*{BT_|f=egqtucEtjRJJhSf)tiBhpPDpgzOpG12UgvOFnab&16Zn^2ZHjs)pbd&W1jpx%%EXmE^ zdn#R73^BHp3w%&v!0~azw(Fg*TT*~5#dJw%-UdxX&^^(~V&C4hBpc+bPcLRZizWlc zjR;$4X3Sw*Rp4-o+a4$cUmrz05RucTNoXRINYG*DPpzM&;d1GNHFiyl(_x#wspacQ zL)wVFXz2Rh0k5i>?Ao5zEVzT)R(4Pjmjv5pzPrav{T(bgr|CM4jH1wDp6z*_jnN{V ziN56m1T)PBp1%`OCFYcJJ+T09`=&=Y$Z#!0l0J2sIuGQtAr>dLfq5S;{XGJzNk@a^ zk^eHlC4Gch`t+ue3RviiOlhz81CD9z~d|n5;A>AGtkZMUQ#f>5M14f2d}2 z8<*LNZvYVob!p9lbmb!0jt)xn6O&JS)`}7v}j+csS3e;&Awj zoNyjnqLzC(QQ;!jvEYUTy73t_%16p)qMb?ihbU{y$i?=a7@JJoXS!#CE#y}PGMK~3 zeeqqmo7G-W_S97s2eed^erB2qeh4P25)RO1>MH7ai5cZJTEevogLNii=oKG)0(&f` z&hh8cO{of0;6KiNWZ6q$cO(1)9r{`}Q&%p*O0W7N--sw3Us;)EJgB)6iSOg(9p_mc zRw{M^qf|?rs2wGPtjVKTOMAfQ+ZNNkb$Ok0;Pe=dNc7__TPCzw^H$5J0l4D z%p(_0w(oLmn0)YDwrcFsc*8q)J@ORBRoZ54GkJpxSvnagp|8H5sxB|ZKirp%_mQt_ z81+*Y8{0Oy!r8Gmih48VuRPwoO$dDW@h53$C)duL4_(osryhwZSj%~KsZ?2n?b`Z* z#C8aMdZxYmCWSM{mFNw1ov*W}Dl=%GQpp90qgZ{(T}GOS8#>sbiEU;zYvA?=wbD5g+ahbd1#s`=| zV6&f#ofJC261~Ua6>0M$w?V1j##jh-lBJ2vQ%&z`7pO%frhLP-1l)wMs=3Q&?oth1 zefkPr@3Z(&OL@~|<0X-)?!AdK)ShtFJ;84G2(izo3cCuKc{>`+aDoziL z6gLTL(=RYeD7x^FYA%sPXswOKhVa4i(S4>h&mLvS##6-H?w8q!B<8Alk>nQEwUG)SFXK zETfcTwi=R3!ck|hSM`|-^N3NWLav&UTO{a9=&Tuz-Kq963;XaRFq#-1R18fi^Gb-; zVO>Q{Oe<^b0WA!hkBi9iJp3`kGwacXX2CVQ0xQn@Y2OhrM%e4)Ea7Y*Df$dY2BpbL zv$kX}*#`R1uNA(7lk_FAk~{~9Z*Si5xd(WKQdD&I?8Y^cK|9H&huMU1I(251D7(LL z+){kRc=ALmD;#SH#YJ+|7EJL6e~w!D7_IrK5Q=1DCulUcN(3j`+D_a|GP}?KYx}V+ zx_vLTYCLb0C?h;e<{K0`)-|-qfM16y{mnfX(GGs2H-;-lRMXyb@kiY^D;i1haxoEk zsQ7C_o2wv?;3KS_0w^G5#Qgf*>u)3bT<3kGQL-z#YiN9QH7<(oDdNlSdeHD zQJN-U*_wJM_cU}1YOH=m>DW~{%MAPxL;gLdU6S5xLb$gJt#4c2KYaEaL8ORWf=^(l z-2`8^J;&YG@vb9em%s~QpU)gG@24BQD69;*y&-#0NBkxumqg#YYomd2tyo0NGCr8N z5<5-E%utH?Ixt!(Y4x>zIz4R^9SABVMpLl(>oXnBNWs8w&xygh_e4*I$y_cVm?W-^ ze!9mPy^vTLRclXRGf$>g%Y{(#Bbm2xxr_Mrsvd7ci|X|`qGe5=54Zt2Tb)N zlykxE&re1ny+O7g#`6e_zyjVjRi5!DeTvSJ9^BJqQ*ovJ%?dkaQl!8r{F`@KuDEJB3#ho5 zmT$A&L=?}gF+!YACb=%Y@}8{SnhaGCHRmmuAh{LxAn0sg#R6P_^cJ-9)+-{YU@<^- zlYnH&^;mLVYE+tyjFj4gaAPCD4CnwP75BBXA`O*H(ULnYD!7K14C!kGL_&hak)udZ zkQN8)EAh&9I|TY~F{Z6mBv7sz3?<^o(#(NXGL898S3yZPTaT|CzZpZ~pK~*9Zcf2F zgwuG)jy^OTZD`|wf&bEdq4Vt$ir-+qM7BosXvu`>W1;iFN7yTvcpN_#at)Q4n+(Jh zYX1A-24l9H5jgY?wdEbW{(6U1=Kc?Utren80bP`K?J0+v@{-RDA7Y8yJYafdI<7-I z_XA!xeh#R4N7>rJ_?(VECa6iWhMJ$qdK0Ms27xG&$gLAy(|SO7_M|AH`fIY)1FGDp zlsLwIDshDU;*n`dF@8vV;B4~jRFpiHrJhQ6TcEm%OjWTi+KmE7+X{19 z>e!sg0--lE2(S0tK}zD&ov-{6bMUc%dNFIn{2^vjXWlt>+uxw#d)T6HNk6MjsfN~4 zDlq#Jjp_!wn}$wfs!f8NX3Rk#9)Q6-jD;D9D=1{$`3?o~caZjXU*U32^JkJ$ZzJ_% zQWNfcImxb!AV1DRBq`-qTV@g1#BT>TlvktYOBviCY!13Bv?_hGYDK}MINVi;pg)V- z($Bx1Tj`c?1I3pYg+i_cvFtcQ$SV9%%9QBPg&8R~Ig$eL+xKZY!C=;M1|r)$&9J2x z;l^a*Ph+isNl*%y1T4SviuK1Nco_spQ25v5-}7u?T9zHB5~{-+W*y3p{yjn{1obqf zYL`J^Uz8zZZN8c4Dxy~)k3Ws)E5eYi+V2C!+7Sm0uu{xq)S8o{9uszFTnE>lPhY=5 zdke-B8_*KwWOd%tQs_zf0x9+YixHp+Qi_V$aYVc$P-1mg?2|_{BUr$6WtLdIX2FaF zGmPRTrdIz)DNE)j*_>b9E}sp*(1-16}u za`dgT`KtA3;+e~9{KV48RT=CGPaVt;>-35}%nlFUMK0y7nOjoYds7&Ft~#>0$^ciZ zM}!J5Mz{&|&lyG^bnmh?YtR z*Z5EfDxkrI{QS#Iq752aiA~V)DRlC*2jlA|nCU!@CJwxO#<=j6ssn;muv zhBT9~35VtwsoSLf*(7vl&{u7d_K_CSBMbzr zzyjt&V5O#8VswCRK3AvVbS7U5(KvTPyUc0BhQ}wy0z3LjcdqH8`6F3!`)b3(mOSxL z>i4f8xor(#V+&#ph~ycJMcj#qeehjxt=~Na>dx#Tcq6Xi4?BnDeu5WBBxt603*BY& zZ#;o1kv?qpZjwK-E{8r4v1@g*lwb|8w@oR3BTDcbiGKs)a>Fpxfzh&b ziQANuJ_tNHdx;a*JeCo^RkGC$(TXS;jnxk=dx++D8|dmPP<0@ z$wh#ZYI%Rx$NKe-)BlJzB*bot0ras3I%`#HTMDthGtM_G6u-(tSroGp1Lz+W1Y`$@ zP`9NK^|IHbBrJ#AL3!X*g3{arc@)nuqa{=*2y+DvSwE=f*{>z1HX(>V zNE$>bbc}_yAu4OVn;8LG^naq5HZY zh{Hec==MD+kJhy6t=Nro&+V)RqORK&ssAxioc7-L#UQuPi#3V2pzfh6Ar400@iuV5 z@r>+{-yOZ%XQhsSfw%;|a4}XHaloW#uGluLKux0II9S1W4w=X9J=(k&8KU()m}b{H zFtoD$u5JlGfpX^&SXHlp$J~wk|DL^YVNh2w(oZ~1*W156YRmenU;g=mI zw({B(QVo2JpJ?pJqu9vijk$Cn+%PSw&b4c@uU6vw)DjGm2WJKt!X}uZ43XYlDIz%& z=~RlgZpU-tu_rD`5!t?289PTyQ zZgAEp=zMK>RW9^~gyc*x%vG;l+c-V?}Bm;^{RpgbEnt_B!FqvnvSy)T=R zGa!5GACDk{9801o@j>L8IbKp#!*Td5@vgFKI4w!5?R{>@^hd8ax{l=vQnd2RDHopo zwA+qb2cu4Rx9^Bu1WNYT`a(g}=&&vT`&Sqn-irxzX_j1=tIE#li`Hn=ht4KQXp zzZj`JO+wojs0dRA#(bXBOFn**o+7rPY{bM9m<+UBF{orv$#yF8)AiOWfuas5Fo`CJ zqa;jAZU^!bh8sjE7fsoPn%Tw11+vufr;NMm3*zC=;jB{R49e~BDeMR+H6MGzDlcA^ zKg>JEL~6_6iaR4i`tSfUhkgPaLXZ<@L7poRF?dw_DzodYG{Gp7#24<}=18PBT}aY` z{)rrt`g}930jr3^RBQNA$j!vzTh#Mo1VL`QCA&US?;<2`P+xy8b9D_Hz>FGHC2r$m zW>S9ywTSdQI5hh%7^e`#r#2906T?))i59O(V^Rpxw42rCAu-+I3y#Pg6cm#&AX%dy ze=hv0cUMxxxh1NQEIYXR{IBM&Bk8FK3NZI3z+M>r@A$ocd*e%x-?W;M0pv50p+MVt zugo<@_ij*6RZ;IPtT_sOf2Zv}-3R_1=sW37GgaF9Ti(>V z1L4ju8RzM%&(B}JpnHSVSs2LH#_&@`4Kg1)>*)^i`9-^JiPE@=4l$+?NbAP?44hX&XAZy&?}1;=8c(e0#-3bltVWg6h=k!(mCx=6DqOJ-I!-(g;*f~DDe={{JGtH7=UY|0F zNk(YyXsGi;g%hB8x)QLpp;;`~4rx>zr3?A|W$>xj>^D~%CyzRctVqtiIz7O3pc@r@JdGJiH@%XR_9vaYoV?J3K1cT%g1xOYqhXfSa`fg=bCLy% zWG74UTdouXiH$?H()lyx6QXt}AS)cOa~3IdBxddcQp;(H-O}btpXR-iwZ5E)di9Jf zfToEu%bOR11xf=Knw7JovRJJ#xZDgAvhBDF<8mDu+Q|!}Z?m_=Oy%Ur4p<71cD@0OGZW+{-1QT?U%_PJJ8T!0d2*a9I2;%|A z9LrfBU!r9qh4=3Mm3nR_~X-EyNc<;?m`?dKUNetCnS)}_-%QcWuOpw zAdZF`4c_24z&m{H9-LIL`=Hrx%{IjrNZ~U<7k6p{_wRkR84g>`eUBOQd3x5 zT^kISYq)gGw?IB8(lu1=$#Vl?iZdrx$H0%NxW)?MO$MhRHn8$F^&mzfMCu>|`{)FL z`ZgOt`z%W~^&kzMAuWy9=q~$ldBftH0}T#(K5e8;j~!x$JjyspJ1IISI?ON5OIPB$ z-5_|YUMb+QUsiv3R%Ys4tVYW+x$}dg;hw%EdoH%SXMp`)v?cxR4wic{X9pVBH>=`#`Kcj!}x4 zV!`6tj|*q?jZdG(CSevn(}4Ogij5 z-kp;sZs}7oNu0x+NHs~(aWaKGV@l~TBkmW&mPj==N!f|1e1SndS6(rPxsn7dz$q_{ zL0jSrihO)1t?gh8N zosMjR3n#YC()CVKv zos2TbnL&)lHEIiYdz|%6N^vAUvTs6?s|~kwI4uXjc9fim`KCqW3D838Xu{48p$2?I zOeEqQe1}JUZECrZSO_m=2<$^rB#B6?nrFXFpi8jw)NmoKV^*Utg6i8aEW|^QNJuW& z4cbXpHSp4|7~TW(%JP%q9W2~@&@5Y5%cXL#fMhV59AGj<3$Hhtfa>24DLk{7GZUtr z5ql**-e58|mbz%5Kk~|f!;g+Ze^b);F+5~^jdoq#m+s?Y*+=d5ruym%-Tnn8htCV; zDyyUrWydgDNM&bI{yp<_wd-q&?Ig+BN-^JjWo6Zu3%Eov^Ja>%eKqrk&7kUqeM8PL zs5D}lTe_Yx;e=K`TDya!-u%y$)r*Cr4bSfN*eZk$XT(Lv2Y}qj&_UaiTevxs_=HXjnOuBpmT> zBg|ty8?|1rD1~Ev^6=C$L9%+RkmBSQxlnj3j$XN?%QBstXdx+Vl!N$f2Ey`i3p@!f zzqhI3jC(TZUx|sP%yValu^nzEV96o%*CljO>I_YKa8wMfc3$_L()k4PB6kglP@IT#wBd*3RITYADL}g+hlzLYxFmCt=_XWS}=jg8`RgJefB57z(2n&&q>m ze&F(YMmoRZW7sQ;cZgd(!A9>7mQ2d#!-?$%G8IQ0`p1|*L&P$GnU0i0^(S;Rua4v8 z_7Qhmv#@+kjS-M|($c*ZOo?V2PgT;GKJyP1REABlZhPyf!kR(0UA7Bww~R<7_u6#t z{XNbiKT&tjne(&=UDZ+gNxf&@9EV|fblS^gxNhI-DH;|`1!YNlMcC{d7I{u_E~cJOalFEzDY|I?S3kHtbrN&}R3k zK(Ph_Ty}*L3Et6$cUW`0}**BY@44KtwEy(jW@pAt`>g> z&8>-TmJiDwc;H%Ae%k6$ndZlfKruu1GocgZrLN=sYI52}_I%d)~ z6z40!%W4I6ch$CE2m>Dl3iwWIbcm27QNY#J!}3hqc&~(F8K{^gIT6E&L!APVaQhj^ zjTJEO&?**pivl^xqfD(rpLu;`Tm1MV+Wtd4u>X6u5V{Yp%)xH$k410o{pGoKdtY0t@GgqFN zO=!hTcYoa^dEPKvPX4ukgUTmR#q840gRMMi%{3kvh9gt(wK;Fniqu9A%BMsq?U&B5DFXC8t8FBN1&UIwS#=S zF(6^Eyn8T}p)4)yRvs2rCXZ{L?N6{hgE_dkH_HA#L3a0$@UMoBw6RE9h|k_rx~%rB zUqeEPL|!Pbp|up2Q=8AcUxflck(fPNJYP1OM_4I(bc24a**Qnd-@;Bkb^2z8Xv?;3yZp*| zoy9KhLo=;8n0rPdQ}yAoS8eb zAtG5QYB|~z@Z(Fxdu`LmoO>f&(JzsO|v0V?1HYsfMvF!3| zka=}6U13(l@$9&=1!CLTCMS~L01CMs@Abl4^Q^YgVgizWaJa%{7t)2sVcZg0mh7>d z(tN=$5$r?s={yA@IX~2ot9`ZGjUgVlul$IU4N}{ zIFBzY3O0;g$BZ#X|VjuTPKyw*|IJ+&pQ` z(NpzU`o=D86kZ3E5#!3Ry$#0AW!6wZe)_xZ8EPidvJ0f+MQJZ6|ZJ$CEV6;Yt{OJnL`dewc1k>AGbkK9Gf5BbB-fg? zgC4#CPYX+9%LLHg@=c;_Vai_~#ksI~)5|9k(W()g6ylc(wP2uSeJ$QLATtq%e#zpT zp^6Y)bV+e_pqIE7#-hURQhfQvIZpMUzD8&-t$esrKJ}4`ZhT|woYi>rP~y~LRf`*2!6 z6prDzJ~1VOlYhYAuBHcu9m>k_F>;N3rpLg>pr;{EDkeQPHfPv~woj$?UTF=txmaZy z?RrVthxVcqUM;X*(=UNg4(L|0d250Xk)6GF&DKD@r6{aZo;(}dnO5@CP7pMmdsI)- zeYH*@#+|)L8x7)@GNBu0Npyyh6r z^~!3$x&w8N)T;|LVgnwx1jHmZn{b2V zO|8s#F0NZhvux?0W9NH5;qZ?P_JtPW86)4J>AS{0F1S0d}=L2`{F z_y;o;17%{j4I)znptnB z%No1W>o}H2%?~CFo~0j?pzWk?dV4ayb!s{#>Yj`ZJ!H)xn}*Z_gFHy~JDis)?9-P=z4iOQg{26~n?dTms7)+F}? zcXvnHHnnbNTzc!$t+V}=<2L<7l(84v1I3b;-)F*Q?cwLNlgg{zi#iS)*rQ5AFWe&~ zWHPPGy{8wEC9JSL?qNVY76=es`bA{vUr~L7f9G@mP}2MNF0Qhv6Sgs`r_k!qRbSXK zv16Qqq`rFM9!4zCrCeiVS~P2e{Pw^A8I?p?NSVR{XfwlQo*wj|Ctqz4X-j+dU7eGkC(2y`(P?FM?P4gKki3Msw#fM6paBq#VNc>T2@``L{DlnnA-_*i10Kre&@-H!Z7gzn9pRF61?^^ z8dJ5kEeVKb%Bly}6NLV}<0(*eZM$QTLcH#+@iWS^>$Of_@Mu1JwM!>&3evymgY6>C_)sK+n|A5G6(3RJz0k>(z2uLdzXeTw)e4*g!h} zn*UvIx-Ozx<3rCF#C`khSv`Y-b&R4gX>d5osr$6jlq^8vi!M$QGx05pJZoY#RGr*J zsJmOhfodAzYQxv-MoU?m_|h^aEwgEHt5h_HMkHwtE+OA03(7{hm1V?AlYAS7G$u5n zO+6?51qo@aQK5#l6pM`kD5OmI28g!J2Z{5kNlSuKl=Yj3QZ|bvVHU}FlM+{QV=<=) z+b|%Q!R)FE z@ycDMSKV2?*XfcAc5@IOrSI&3&aR$|oAD8WNA6O;p~q-J@ll{x`jP<*eEpIYOYnT zer_t=dYw6a0avjQtKN&#n&(KJ5Kr$RXPOp1@Fq#0Of zTXQkq4qQxKWR>x#d{Hyh?6Y)U07;Q$?BTl7mx2bSPY_juXub1 z%-$)NKXzE<%}q>RX25*oeMVjiz&r_z;BrQV-(u>!U>C*OisXNU*UftsrH6vAhTEm@ zoKA`?fZL1sdd!+G@*NNvZa>}37u^x8^T>VH0_6Bx{3@x5NAg&55{2jUE-w3zCJNJi z^IlU=+DJz-9K&4c@7iKj(zlj@%V}27?vYmxo*;!jZVXJMeDg;5T!4Y1rxNV-e$WAu zkk6^Xao8HC=w2hpLvM(!xwo|~$eG6jJj39zyQHf)E+NPJlfspUhzRv&_qr8+Z1`DA zz`EV=A)d=;2&J;eypNx~q&Ir_7e_^xXg(L9>k=X4pxZ3y#-ch$^TN}i>X&uwF%75c(9cjO6`E5 z16vbMYb!lEIM?jxn)^+Ld8*hmEXR4a8TSfqwBg1(@^8$p&#@?iyGd}uhWTVS`Mlpa zGc+kV)K7DJwd46aco@=?iASsx?sDjbHoDVU9=+^tk46|Fxxey1u)_}c1j z^(`5~PU%og1LdSBE5x4N&5&%Nh$sy0oANXwUcGa>@CCMqP`4W$ZPSaykK|giiuMIw zu#j)&VRKWP55I(5K1^cog|iXgaK1Z%wm%T;;M3X`-`TTWaI}NtIZj;CS)S%S(h}qq zRFQ#{m4Qk$7;1i*0PC^|X1@a1pcMq1aiRSCHq+mnfj^FS{oxWs0McCN-lK4>SDp#` z7=Duh)kXC;lr1g3dqogzBBDg6>et<<>m>KO^|bI5X{+eMd^-$2xfoP*&e$vdQc7J% zmFO~OHf7aqlIvg%P`Gu|3n;lKjtRd@;;x#$>_xU(HpZos7?ShZlQSU)bY?qyQM3cHh5twS6^bF8NBKDnJgXHa)? zBYv=GjsZuYC2QFS+jc#uCsaEPEzLSJCL=}SIk9!*2Eo(V*SAUqKw#?um$mUIbqQQb zF1Nn(y?7;gP#@ws$W76>TuGcG=U_f6q2uJq?j#mv7g;llvqu{Yk~Mo>id)jMD7;T> zSB$1!g)QpIf*f}IgmV;!B+3u(ifW%xrD=`RKt*PDC?M5KI)DO`VXw(7X-OMLd3iVU z0CihUN(eNrY;m?vwK{55MU`p1;JDF=6ITN$+!q8W#`iIsN8;W7H?`htf%RS9Lh+KQ z_p_4?qO4#*`t+8l-N|kAKDcOt zoHsqz_oO&n?@4^Mr*4YrkDX44BeS*0zaA1j@*c}{$;jUxRXx1rq7z^*NX6d`DcQ}L z6*cN7e%`2#_J4z8=^GM6>%*i>>X^_0u9qn%0JTUo)c0zIz|7a`%_UnB)-I1cc+ z0}jAK0}jBl|6-2VT759oxBnf%-;7vs>7Mr}0h3^$0`5FAy}2h{ps5%RJA|^~6uCqg zxBMK5bQVD{Aduh1lu4)`Up*&( zCJQ>nafDb#MuhSZ5>YmD@|TcrNv~Q%!tca;tyy8Iy2vu2CeA+AsV^q*Wohg%69XYq zP0ppEDEYJ9>Se&X(v=U#ibxg()m=83pLc*|otbG;`CYZ z*YgsakGO$E$E_$|3bns7`m9ARe%myU3$DE;RoQ<6hR8e;%`pxO1{GXb$cCZl9lVnJ$(c` z``G?|PhXaz`>)rb7jm2#v7=(W?@ zjUhrNndRFMQ}%^^(-nmD&J>}9w@)>l;mhRr@$}|4ueOd?U9ZfO-oi%^n4{#V`i}#f zqh<@f^%~(MnS?Z0xsQI|Fghrby<&{FA+e4a>c(yxFL!Pi#?DW!!YI{OmR{xEC7T7k zS_g*9VWI}d0IvIXx*d5<7$5Vs=2^=ews4qZGmAVyC^9e;wxJ%BmB(F5*&!yyABCtLVGL@`qW>X9K zpv=W~+EszGef=am3LG+#yIq5oLXMnZ_dxSLQ_&bwjC^0e8qN@v!p?7mg02H<9`uaJ zy0GKA&YQV2CxynI3T&J*m!rf4@J*eo235*!cB1zEMQZ%h5>GBF;8r37K0h?@|E*0A zIHUg0y7zm(rFKvJS48W7RJwl!i~<6X2Zw+Fbm9ekev0M;#MS=Y5P(kq^(#q11zsvq zDIppe@xOMnsOIK+5BTFB=cWLalK#{3eE>&7fd11>l2=MpNKjsZT2kmG!jCQh`~Fu0 z9P0ab`$3!r`1yz8>_7DYsO|h$kIsMh__s*^KXv?Z1O8|~sEz?Y{+GDzze^GPjk$E$ zXbA-1gd77#=tn)YKU=;JE?}De0)WrT%H9s3`fn|%YibEdyZov3|MJ>QWS>290eCZj z58i<*>dC9=kz?s$sP_9kK1p>nV3qvbleExyq56|o+oQsb{ZVmuu1n~JG z0sUvo_i4fSM>xRs8rvG$*+~GZof}&ISxn(2JU*K{L<3+b{bBw{68H&Uiup@;fWWl5 zgB?IWMab0LkXK(Hz#yq>scZbd2%=B?DO~^q9tarlzZysN+g}n0+v);JhbjUT8AYrt z3?;0r%p9zLJv1r$%q&HKF@;3~0wVwO!U5m;J`Mm|`Nc^80sZd+Wj}21*SPoF82hCF zoK?Vw;4ioafdAkZxT1er-LLVi-*0`@2Ur&*!b?0U>R;no+S%)xoBuBxRw$?weN-u~tKE}8xb@7Gs%(aC;e1-LIlSfXDK(faFW)mnHdrLc3`F z6ZBsT^u0uVS&il=>YVX^*5`k!P4g1)2LQmz{?&dgf`7JrA4ZeE0sikL`k!Eb6r=g0 z{aCy_0I>fxSAXQYz3lw5G|ivg^L@(x-uch!AphH+d;E4`175`R0#b^)Zp>EM1Ks=zx6_261>!7 z{7F#a{Tl@Tpw9S`>7_i|PbScS-(dPJv9_0-FBP_aa@Gg^2IoKNZM~#=sW$SH3MJ|{ zsQy8F43lX7hYx<{v^Q9`2QsMzeen3cGpiTgzVp- z`aj3&Wv0(he1qKI!2jpGpO-i0Wpcz%vdn`2o9x&3;^nsZPt3c \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 24467a1..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,100 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/java-snapshot-testing-core/build.gradle b/java-snapshot-testing-core/build.gradle deleted file mode 100644 index 85b6954..0000000 --- a/java-snapshot-testing-core/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -apply from: "../gradle/publishing.gradle" -apply from: "../gradle/spotless.gradle" - -dependencies { - compileOnly 'com.fasterxml.jackson.core:jackson-core:2.20.1' - compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.20.1' - - implementation 'org.assertj:assertj-core:3.11.1' - implementation 'org.opentest4j:opentest4j:1.2.0' - - testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' - testImplementation 'org.mockito:mockito-junit-jupiter:2.23.0' - testImplementation 'org.mockito:mockito-core:2.23.4' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' - testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.3.2' - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.3.2' - testImplementation group: 'commons-io', name: 'commons-io', version: '2.6' -} - -test { useJUnitPlatform() } - -publishing { - publications { - myPublication(MavenPublication) { - artifact shadowJar - groupId 'io.github.origin-energy' - artifactId 'java-snapshot-testing-core' - } - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java deleted file mode 100644 index 7269121..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java +++ /dev/null @@ -1,172 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; - -@RequiredArgsConstructor -public class Expect { - private final SnapshotVerifier snapshotVerifier; - private final Method testMethod; - - private SnapshotSerializer snapshotSerializer; - private SnapshotComparator snapshotComparator; - private List snapshotReporters; - private String scenario; - - private final Map headers = new HashMap<>(); - - public static Expect of(SnapshotVerifier snapshotVerifier, Method method) { - return new Expect(snapshotVerifier, method); - } - - /** - * Make an assertion on the given input parameters against what already exists - * - *

If you were previously using varargs and see an error - you can fix the error using - * "toMatchSnapshotLegacy", however, a better approach is to use the ".scenario()" feature as - * future versions of this library will most likely remove the legacy implementation completely. - * - * @param object snapshot object - */ - public void toMatchSnapshot(Object object) { - SnapshotContext snapshotContext = snapshotVerifier.expectCondition(testMethod, object); - if (snapshotSerializer != null) { - snapshotContext.setSnapshotSerializer(snapshotSerializer); - } - if (snapshotComparator != null) { - snapshotContext.setSnapshotComparator(snapshotComparator); - } - if (snapshotReporters != null) { - snapshotContext.setSnapshotReporters(snapshotReporters); - } - if (scenario != null) { - snapshotContext.setScenario(scenario); - } - snapshotContext.header.putAll(headers); - - snapshotContext.checkValidContext(); - - snapshotContext.toMatchSnapshot(); - } - - /** - * Normally a snapshot can be applied only once to a test method. - * - *

For Parameterized tests where the same method is executed multiple times you can supply the - * scenario() to overcome this restriction. Ensure each scenario is unique. - * - * @param scenario - unique scenario description - * @return Snapshot - */ - public Expect scenario(String scenario) { - this.scenario = scenario; - return this; - } - - /** - * Apply a custom serializer for this snapshot - * - * @param serializer your custom serializer - * @return Snapshot - */ - public Expect serializer(SnapshotSerializer serializer) { - this.snapshotSerializer = serializer; - return this; - } - - /** - * Apply a custom serializer for this snapshot - * - * @param name - the {name} attribute serializer.{name} from snapshot.properties - * @return Snapshot - */ - public Expect serializer(String name) { - this.snapshotSerializer = SnapshotProperties.getInstance("serializer." + name); - return this; - } - - /** - * Apply a custom comparator for this snapshot - * - * @param comparator your custom comparator - * @return Snapshot - */ - public Expect comparator(SnapshotComparator comparator) { - this.snapshotComparator = comparator; - return this; - } - - /** - * Apply a custom comparator for this snapshot - * - * @param name the {name} attribute comparator.{name} from snapshot.properties - * @return Snapshot - */ - public Expect comparator(String name) { - this.snapshotComparator = SnapshotProperties.getInstance("comparator." + name); - return this; - } - - /** - * Apply a list of custom reporters for this snapshot This will replace the default reporters - * defined in the config - * - * @param reporters your custom reporters - * @return Snapshot - */ - public Expect reporters(SnapshotReporter... reporters) { - this.snapshotReporters = Arrays.asList(reporters); - return this; - } - - /** - * Apply a list of custom reporters for this snapshot This will replace the default reporters - * defined in the config - * - * @param name the {name} attribute reporters.{name} from snapshot.properties - * @return Snapshot - */ - public Expect reporters(String name) { - this.snapshotReporters = SnapshotProperties.getInstances("reporters." + name); - return this; - } - - /** - * Apply a custom serializer for this snapshot. - * - * @param serializer your custom serializer - * @return this - * @see au.com.origin.snapshots.serializers.SnapshotSerializer - *

Example implementations - * @see au.com.origin.snapshots.serializers.ToStringSnapshotSerializer - * @see au.com.origin.snapshots.serializers.Base64SnapshotSerializer - */ - @SneakyThrows - public Expect serializer(Class serializer) { - this.snapshotSerializer = serializer.getConstructor().newInstance(); - return this; - } - - /** - * Add anything you like to the snapshot header. - * - *

These custom headers can be used in serializers, comparators or reporters to change how they - * behave. - * - * @param key key - * @param value value - * @return Expect - */ - public Expect header(String key, String value) { - headers.put(key, value); - return this; - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java deleted file mode 100644 index bc57d4d..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java +++ /dev/null @@ -1,80 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.exceptions.LogGithubIssueException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@EqualsAndHashCode -@Builder -@Getter -@RequiredArgsConstructor -public class Snapshot implements Comparable { - - private final String name; - private final String scenario; - private final SnapshotHeader header; - private final String body; - - @Override - public int compareTo(Snapshot other) { - return (name + scenario).compareTo(other.name + other.scenario); - } - - public String getIdentifier() { - return scenario == null ? name : String.format("%s[%s]", name, scenario); - } - - public static Snapshot parse(String rawText) { - String regex = - "^(?.*?)(\\[(?[^]]*)])?=(?

\\{[^}]*?})?(?(.*)$)"; - Pattern p = Pattern.compile(regex, Pattern.DOTALL); - Matcher m = p.matcher(rawText); - boolean found = m.find(); - if (!found) { - throw new LogGithubIssueException( - "Corrupt Snapshot (REGEX matches = 0): possibly due to manual editing or our REGEX failing\n" - + "Possible Solutions\n" - + "1. Ensure you have not accidentally manually edited the snapshot file!\n" - + "2. Compare the snapshot with GIT history"); - } - - String name = m.group("name"); - String scenario = m.group("scenario"); - String header = m.group("header"); - String snapshot = m.group("snapshot"); - - if (name == null || snapshot == null) { - throw new LogGithubIssueException( - "Corrupt Snapshot (REGEX name or snapshot group missing): possibly due to manual editing or our REGEX failing\n" - + "Possible Solutions\n" - + "1. Ensure you have not accidentally manually edited the snapshot file\n" - + "2. Compare the snapshot with your version control history"); - } - - return Snapshot.builder() - .name(name) - .scenario(scenario) - .header(SnapshotHeader.fromJson(header)) - .body(snapshot) - .build(); - } - - /** - * The raw string representation of the snapshot as it would appear in the *.snap file. - * - * @return raw snapshot - */ - public String raw() { - String headerJson = (header == null) || (header.size() == 0) ? "" : header.toJson(); - return getIdentifier() + "=" + headerJson + body; - } - - @Override - public String toString() { - return raw(); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java deleted file mode 100644 index ae0398e..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java +++ /dev/null @@ -1,173 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.ReservedWordException; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.lang.reflect.Method; -import java.util.*; -import java.util.stream.Collectors; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class SnapshotContext { - - private static final List RESERVED_WORDS = Arrays.asList("=", "[", "]"); - - private final SnapshotConfig snapshotConfig; - private final SnapshotFile snapshotFile; - - @Getter final Class testClass; - - @Getter final Method testMethod; - - final Object current; - private final boolean isCI; - - @Setter private SnapshotSerializer snapshotSerializer; - @Setter private SnapshotComparator snapshotComparator; - @Setter private List snapshotReporters; - - @Setter @Getter String scenario; - - @Getter SnapshotHeader header = new SnapshotHeader(); - - SnapshotContext( - SnapshotConfig snapshotConfig, - SnapshotFile snapshotFile, - Class testClass, - Method testMethod, - Object current) { - this.snapshotConfig = snapshotConfig; - this.snapshotFile = snapshotFile; - this.testClass = testClass; - this.testMethod = testMethod; - this.current = current; - - this.isCI = snapshotConfig.isCI(); - this.snapshotSerializer = snapshotConfig.getSerializer(); - this.snapshotComparator = snapshotConfig.getComparator(); - this.snapshotReporters = snapshotConfig.getReporters(); - this.scenario = null; - } - - public void toMatchSnapshot() { - - Set rawSnapshots = snapshotFile.getSnapshots(); - Snapshot previousSnapshot = getRawSnapshot(rawSnapshots); - Snapshot currentSnapshot = takeSnapshot(); - - if (previousSnapshot != null && shouldUpdateSnapshot()) { - snapshotFile.getSnapshots().remove(previousSnapshot); - previousSnapshot = null; - } - - if (previousSnapshot != null) { - snapshotFile.pushDebugSnapshot(currentSnapshot); - - // Match existing Snapshot - if (!snapshotComparator.matches(previousSnapshot, currentSnapshot)) { - snapshotFile.createDebugFile(currentSnapshot); - - List reporters = - snapshotReporters.stream() - .filter(reporter -> reporter.supportsFormat(snapshotSerializer.getOutputFormat())) - .collect(Collectors.toList()); - - if (reporters.isEmpty()) { - String comparator = snapshotComparator.getClass().getSimpleName(); - throw new IllegalStateException( - "No compatible reporters found for comparator " + comparator); - } - - List errors = new ArrayList<>(); - - for (SnapshotReporter reporter : reporters) { - try { - reporter.report(previousSnapshot, currentSnapshot); - } catch (Throwable t) { - errors.add(t); - } - } - - if (!errors.isEmpty()) { - throw new SnapshotMatchException("Error(s) matching snapshot(s)", errors); - } - } - } else { - if (this.isCI) { - log.error( - "We detected you are running on a CI Server - if this is incorrect please override the isCI() method in SnapshotConfig"); - throw new SnapshotMatchException( - "Snapshot [" - + resolveSnapshotIdentifier() - + "] not found. Has this snapshot been committed ?"); - } else { - log.warn( - "We detected you are running on a developer machine - if this is incorrect please override the isCI() method in SnapshotConfig"); - // Create New Snapshot - snapshotFile.pushSnapshot(currentSnapshot); - snapshotFile.pushDebugSnapshot(currentSnapshot); - } - } - } - - private boolean shouldUpdateSnapshot() { - if (snapshotConfig.updateSnapshot().isPresent() && snapshotConfig.isCI()) { - throw new SnapshotExtensionException( - "isCI=true & update-snapshot=" - + snapshotConfig.updateSnapshot() - + ". Updating snapshots on CI is not allowed"); - } - if (snapshotConfig.updateSnapshot().isPresent()) { - return resolveSnapshotIdentifier().contains(snapshotConfig.updateSnapshot().get()); - } else { - return false; - } - } - - private Snapshot getRawSnapshot(Collection rawSnapshots) { - synchronized (rawSnapshots) { - for (Snapshot rawSnapshot : rawSnapshots) { - if (rawSnapshot.getIdentifier().equals(resolveSnapshotIdentifier())) { - return rawSnapshot; - } - } - } - return null; - } - - private Snapshot takeSnapshot() { - SnapshotSerializerContext sg = SnapshotSerializerContext.from(this); - return snapshotSerializer.apply(current, sg); - } - - String resolveSnapshotIdentifier() { - String scenarioFormat = scenario == null ? "" : "[" + scenario + "]"; - return snapshotName() + scenarioFormat; - } - - private String snapshotName() { - SnapshotName snapshotName = testMethod.getAnnotation(SnapshotName.class); - return snapshotName == null - ? testClass.getName() + "." + testMethod.getName() - : snapshotName.value(); - } - - void checkValidContext() { - for (String rw : RESERVED_WORDS) { - if (snapshotName().contains(rw)) { - throw new ReservedWordException("snapshot name", rw, RESERVED_WORDS); - } - if (scenario != null && scenario.contains(rw)) { - throw new ReservedWordException("scenario name", rw, RESERVED_WORDS); - } - } - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java deleted file mode 100644 index 079476f..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java +++ /dev/null @@ -1,169 +0,0 @@ -package au.com.origin.snapshots; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import lombok.Getter; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class SnapshotFile { - - public static final String SPLIT_STRING = "\n\n\n"; - - private final String fileName; - private final Class testClass; - @Getter private Set snapshots = Collections.synchronizedSortedSet(new TreeSet<>()); - private Set debugSnapshots = Collections.synchronizedSortedSet(new TreeSet<>()); - - public SnapshotFile(String srcDirPath, String fileName, Class testClass) throws IOException { - this.testClass = testClass; - this.fileName = srcDirPath + File.separator + fileName; - log.info("Snapshot File: " + this.fileName); - - StringBuilder fileContent = new StringBuilder(); - - try (BufferedReader br = - new BufferedReader( - new InputStreamReader(new FileInputStream(this.fileName), StandardCharsets.UTF_8))) { - - String sCurrentLine; - - while ((sCurrentLine = br.readLine()) != null) { - fileContent.append(sCurrentLine + "\n"); - } - - String fileText = fileContent.toString(); - if (!"".equals(fileText.trim())) { - snapshots = - Collections.synchronizedSortedSet( - Stream.of(fileContent.toString().split(SPLIT_STRING)) - .map(String::trim) - .map(Snapshot::parse) - .collect(Collectors.toCollection(TreeSet::new))); - } - } catch (IOException e) { - // ... - } - - deleteDebugFile(); - } - - private String getDebugFilename() { - return this.fileName + ".debug"; - } - - public File createDebugFile(Snapshot snapshot) { - File file = null; - try { - file = new File(getDebugFilename()); - file.getParentFile().mkdirs(); - file.createNewFile(); - - try (FileOutputStream fileStream = new FileOutputStream(file, false)) { - fileStream.write(snapshot.raw().getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - e.printStackTrace(); - } - } catch (IOException e) { - e.printStackTrace(); - } - - return file; - } - - @SneakyThrows - public void deleteDebugFile() { - Files.deleteIfExists(Paths.get(getDebugFilename())); - } - - @SneakyThrows - public void delete() { - Files.deleteIfExists(Paths.get(this.fileName)); - } - - @SneakyThrows - public synchronized File createFileIfNotExists(String filename) { - Path path = Paths.get(filename); - if (!Files.exists(path)) { - Files.createDirectories(path.getParent()); - Files.createFile(path); - } - return path.toFile(); - } - - public void pushSnapshot(Snapshot snapshot) { - synchronized (snapshots) { - snapshots.add(snapshot); - TreeSet rawSnapshots = - snapshots.stream().map(Snapshot::raw).collect(Collectors.toCollection(TreeSet::new)); - updateFile(this.fileName, rawSnapshots); - } - } - - public synchronized void pushDebugSnapshot(Snapshot snapshot) { - debugSnapshots.add(snapshot); - TreeSet rawDebugSnapshots = - debugSnapshots.stream().map(Snapshot::raw).collect(Collectors.toCollection(TreeSet::new)); - updateFile(getDebugFilename(), rawDebugSnapshots); - } - - private void updateFile(String fileName, Set rawSnapshots) { - File file = createFileIfNotExists(fileName); - try (FileOutputStream fileStream = new FileOutputStream(file, false)) { - byte[] myBytes = String.join(SPLIT_STRING, rawSnapshots).getBytes(StandardCharsets.UTF_8); - fileStream.write(myBytes); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @SneakyThrows - public void cleanup() { - Path path = Paths.get(this.fileName); - if (Files.exists(path)) { - if (Files.size(path) == 0 || snapshotsAreTheSame()) { - deleteDebugFile(); - } - - if (Files.size(path) == 0) { - delete(); - } else { - String content = - new String(Files.readAllBytes(Paths.get(this.fileName)), StandardCharsets.UTF_8); - Files.write( - path, content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING); - } - } - } - - @SneakyThrows - private boolean snapshotsAreTheSame() { - Path path = Paths.get(this.getDebugFilename()); - if (Files.exists(path)) { - List snapshotFileContent = - Files.readAllLines(Paths.get(this.fileName), StandardCharsets.UTF_8); - List debugSnapshotFileContent = - Files.readAllLines(Paths.get(this.getDebugFilename()), StandardCharsets.UTF_8); - return Objects.equals(snapshotFileContent, debugSnapshotFileContent); - } - - return false; - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java deleted file mode 100644 index 1d0419d..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java +++ /dev/null @@ -1,48 +0,0 @@ -package au.com.origin.snapshots; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; - -@RequiredArgsConstructor -public class SnapshotHeader extends HashMap { - - // - // Manual JSON serialization/deserialization as I don't want to - // include another dependency for it - // - @SneakyThrows - public String toJson() { - StringBuilder b = new StringBuilder(); - b.append("{\n"); - final int lastIndex = this.size(); - int currIndex = 0; - for (Map.Entry entry : this.entrySet()) { - currIndex++; - String format = currIndex == lastIndex ? " \"%s\": \"%s\"\n" : " \"%s\": \"%s\",\n"; - b.append(String.format(format, entry.getKey(), entry.getValue())); - } - b.append("}"); - return b.toString(); - } - - @SneakyThrows - public static SnapshotHeader fromJson(String json) { - SnapshotHeader snapshotHeader = new SnapshotHeader(); - - if (json == null) { - return snapshotHeader; - } - - String regex = "\\\"(?.*)\\\": \\\"(?.*)\\\""; - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(json); - while (m.find()) { - snapshotHeader.put(m.group("key"), m.group("value")); - } - return snapshotHeader; - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java deleted file mode 100644 index 3833b7a..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java +++ /dev/null @@ -1,58 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.exceptions.MissingSnapshotPropertiesKeyException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; -import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public enum SnapshotProperties { - INSTANCE; - - Properties snapshotProperties = new Properties(); - - SnapshotProperties() { - try { - InputStream in = - SnapshotProperties.class.getClassLoader().getResourceAsStream("snapshot.properties"); - snapshotProperties.load(in); - } catch (Exception e) { - // It's ok, if the SnapshotConfig implementation attempts to get a property they will receive - // a MissingSnapshotPropertiesKeyException - } - } - - public static String getOrThrow(String key) { - Object value = INSTANCE.snapshotProperties.get(key); - if (value == null) { - throw new MissingSnapshotPropertiesKeyException(key); - } - return value.toString(); - } - - public static T getInstance(String key) { - String value = SnapshotProperties.getOrThrow(key); - return createInstance(value); - } - - public static List getInstances(String key) { - String value = SnapshotProperties.getOrThrow(key); - return Arrays.stream(value.split(",")) - .map(String::trim) - .map(it -> (T) createInstance(it)) - .collect(Collectors.toList()); - } - - @SuppressWarnings("unchecked") - private static T createInstance(String className) { - try { - Class clazz = Class.forName(className); - return (T) clazz.newInstance(); - } catch (Exception e) { - throw new RuntimeException("Unable to instantiate class " + className, e); - } - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java deleted file mode 100644 index b19c31e..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java +++ /dev/null @@ -1,43 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.annotations.SnapshotName; -import java.lang.reflect.Method; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -/** - * Contains details of the pending snapshot that can be modified in the Serializer prior to calling - * toSnapshot(). - */ -@AllArgsConstructor -public class SnapshotSerializerContext { - - @Getter @Setter private String name; - - @Getter @Setter private String scenario; - - @Getter @Setter private SnapshotHeader header; - - @Getter private Class testClass; - - @Getter private final Method testMethod; - - public static SnapshotSerializerContext from(SnapshotContext context) { - SnapshotName snapshotName = context.getTestMethod().getAnnotation(SnapshotName.class); - String name = - snapshotName == null - ? context.getTestClass().getName() + "." + context.getTestMethod().getName() - : snapshotName.value(); - return new SnapshotSerializerContext( - name, - context.getScenario(), - context.getHeader(), - context.getTestClass(), - context.getTestMethod()); - } - - public Snapshot toSnapshot(String body) { - return Snapshot.builder().name(name).scenario(scenario).header(header).body(body).build(); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java deleted file mode 100644 index e6e0f93..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java +++ /dev/null @@ -1,146 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@RequiredArgsConstructor -public class SnapshotVerifier { - - private final Class testClass; - private final SnapshotFile snapshotFile; - private final SnapshotConfig config; - private final boolean failOnOrphans; - - private final Collection calledSnapshots = - Collections.synchronizedCollection(new ArrayList<>()); - - public SnapshotVerifier(SnapshotConfig frameworkSnapshotConfig, Class testClass) { - this(frameworkSnapshotConfig, testClass, false); - } - - /** - * Instantiate before any tests have run for a given class - * - * @param frameworkSnapshotConfig configuration to use - * @param failOnOrphans should the test break if snapshots exist with no matching method in the - * test class - * @param testClass reference to class under test - */ - public SnapshotVerifier( - SnapshotConfig frameworkSnapshotConfig, Class testClass, boolean failOnOrphans) { - try { - verifyNoConflictingSnapshotNames(testClass); - - UseSnapshotConfig customConfig = testClass.getAnnotation(UseSnapshotConfig.class); - SnapshotConfig snapshotConfig = - customConfig == null ? frameworkSnapshotConfig : customConfig.value().newInstance(); - - // Matcher.quoteReplacement required for Windows - String testFilename = - testClass.getName().replaceAll("\\.", Matcher.quoteReplacement(File.separator)) + ".snap"; - - File fileUnderTest = new File(testFilename); - File snapshotDir = new File(fileUnderTest.getParentFile(), snapshotConfig.getSnapshotDir()); - - // Support legacy trailing space syntax - String testSrcDir = snapshotConfig.getOutputDir(); - String testSrcDirNoTrailing = - testSrcDir.endsWith("/") ? testSrcDir.substring(0, testSrcDir.length() - 1) : testSrcDir; - SnapshotFile snapshotFile = - new SnapshotFile( - testSrcDirNoTrailing, - snapshotDir.getPath() + File.separator + fileUnderTest.getName(), - testClass); - - this.testClass = testClass; - this.snapshotFile = snapshotFile; - this.config = snapshotConfig; - this.failOnOrphans = failOnOrphans; - - } catch (IOException | InstantiationException | IllegalAccessException e) { - throw new SnapshotExtensionException(e.getMessage()); - } - } - - private void verifyNoConflictingSnapshotNames(Class testClass) { - Map> allSnapshotAnnotationNames = - Arrays.stream(testClass.getDeclaredMethods()) - .filter(it -> it.isAnnotationPresent(SnapshotName.class)) - .map(it -> it.getAnnotation(SnapshotName.class)) - .map(SnapshotName::value) - .collect(Collectors.groupingBy(String::toString)); - - boolean hasDuplicateSnapshotNames = - allSnapshotAnnotationNames.entrySet().stream() - .filter(it -> it.getValue().size() > 1) - .peek( - it -> - log.error( - "Oops, looks like you set the same name of two separate snapshots @SnapshotName(\"{}\") in class {}", - it.getKey(), - testClass.getName())) - .count() - > 0; - if (hasDuplicateSnapshotNames) { - throw new SnapshotExtensionException("Duplicate @SnapshotName annotations found!"); - } - } - - @SneakyThrows - public SnapshotContext expectCondition(Method testMethod, Object object) { - SnapshotContext snapshotContext = - new SnapshotContext(config, snapshotFile, testClass, testMethod, object); - calledSnapshots.add(snapshotContext); - return snapshotContext; - } - - public void validateSnapshots() { - Set rawSnapshots = snapshotFile.getSnapshots(); - Set snapshotNames = - calledSnapshots.stream() - .map(SnapshotContext::resolveSnapshotIdentifier) - .collect(Collectors.toSet()); - List unusedSnapshots = new ArrayList<>(); - - for (Snapshot rawSnapshot : rawSnapshots) { - boolean foundSnapshot = false; - for (String snapshotName : snapshotNames) { - if (rawSnapshot.getIdentifier().equals(snapshotName)) { - foundSnapshot = true; - break; - } - } - if (!foundSnapshot) { - unusedSnapshots.add(rawSnapshot); - } - } - if (unusedSnapshots.size() > 0) { - List unusedRawSnapshots = - unusedSnapshots.stream().map(Snapshot::raw).collect(Collectors.toList()); - String errorMessage = - "All unused Snapshots:\n" - + String.join("\n", unusedRawSnapshots) - + "\n\nHave you deleted tests? Have you renamed a test method?"; - if (failOnOrphans) { - log.error(errorMessage); - throw new SnapshotMatchException("ERROR: Found orphan snapshots"); - } else { - log.warn(errorMessage); - } - } - snapshotFile.cleanup(); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java deleted file mode 100644 index 2fa029e..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java +++ /dev/null @@ -1,11 +0,0 @@ -package au.com.origin.snapshots.annotations; - -import java.lang.annotation.*; - -@Documented -@Target({ElementType.METHOD}) -@Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface SnapshotName { - String value(); -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java deleted file mode 100644 index 61e4453..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -package au.com.origin.snapshots.annotations; - -import au.com.origin.snapshots.config.SnapshotConfig; -import java.lang.annotation.*; - -@Documented -@Target({ElementType.TYPE}) -@Inherited -@Retention(RetentionPolicy.RUNTIME) -public @interface UseSnapshotConfig { - Class value(); -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java deleted file mode 100644 index 05d4a8a..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java +++ /dev/null @@ -1,77 +0,0 @@ -package au.com.origin.snapshots.config; - -import au.com.origin.snapshots.SnapshotProperties; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.exceptions.MissingSnapshotPropertiesKeyException; -import au.com.origin.snapshots.logging.LoggingHelper; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.util.List; -import java.util.Optional; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class PropertyResolvingSnapshotConfig implements SnapshotConfig { - - @Override - public String getOutputDir() { - return SnapshotProperties.getOrThrow("output-dir"); - } - - @Override - public String getSnapshotDir() { - return SnapshotProperties.getOrThrow("snapshot-dir"); - } - - @Override - public Optional updateSnapshot() { - // This was the original way to update snapshots - Optional legacyFlag = - Optional.ofNullable(System.getProperty(JVM_UPDATE_SNAPSHOTS_PARAMETER)); - if (legacyFlag.isPresent()) { - LoggingHelper.deprecatedV5( - log, - "Passing -PupdateSnapshot will be removed in a future release. Consider using snapshot.properties 'update-snapshot' toggle instead"); - if ("false".equals(legacyFlag.get())) { - return Optional.empty(); - } - return legacyFlag; - } - - try { - String updateSnapshot = SnapshotProperties.getOrThrow("update-snapshot"); - if ("all".equals(updateSnapshot)) { - return Optional.of(""); - } else if ("none".equals(updateSnapshot)) { - return Optional.empty(); - } - return Optional.of(updateSnapshot); - } catch (MissingSnapshotPropertiesKeyException ex) { - LoggingHelper.deprecatedV5( - log, - "You do not have 'update-snapshot=none' defined in your snapshot.properties - consider adding it now"); - return Optional.empty(); - } - } - - @Override - public SnapshotSerializer getSerializer() { - return SnapshotProperties.getInstance("serializer"); - } - - @Override - public SnapshotComparator getComparator() { - return SnapshotProperties.getInstance("comparator"); - } - - @Override - public List getReporters() { - return SnapshotProperties.getInstances("reporters"); - } - - @Override - public boolean isCI() { - String envVariable = SnapshotProperties.getOrThrow("ci-env-var"); - return System.getenv(envVariable) != null; - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java deleted file mode 100644 index 45bdeae..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java +++ /dev/null @@ -1,86 +0,0 @@ -package au.com.origin.snapshots.config; - -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.util.List; -import java.util.Optional; - -/** - * Snapshot Configuration ---------------------- - * - *

Implement this interface when integrating `java-snapshot-testing` with a custom testing - * library - */ -public interface SnapshotConfig { - @Deprecated String JVM_UPDATE_SNAPSHOTS_PARAMETER = "updateSnapshot"; - - /** - * The base directory where files get written (excluding package directories) default: - * "src/test/java" - * - *

You might want to override if you have tests under "src/test/integration" for example - * - * @return snapshot output folder - */ - String getOutputDir(); - - /** - * Subdirectory to store snapshots in - * - * @return name of subdirectory - */ - String getSnapshotDir(); - - /** - * Optional - * - * @return snapshots should be updated automatically without verification - */ - default Optional updateSnapshot() { - return Optional.ofNullable(System.getProperty(JVM_UPDATE_SNAPSHOTS_PARAMETER)); - } - - /** - * Optional Override to supply your own custom serialization function - * - * @return custom serialization function - */ - SnapshotSerializer getSerializer(); - - /** - * Optional Override to supply your own custom comparator function - * - * @return custom comparator function - */ - SnapshotComparator getComparator(); - - /** - * Optional Override to supply your own custom reporter functions Reporters will run in the same - * sequence as provided. Reporters should throw exceptions to indicate comparison failure. - * Exceptions thrown from reporters are aggregated and reported together. Reporters that wish to - * leverage IDE comparison tools can use standard assertion libraries like assertj, junit jupiter - * assertions (or) opentest4j. - * - * @return custom reporter functions - */ - List getReporters(); - - /** - * Optional This method is meant to detect if we're running on a CI environment. This is used to - * determine the action to be taken when a snapshot is not found. - * - *

If this method returns false, meaning we're NOT running on a CI environment (probably a dev - * machine), a new snapshot is created when not found. - * - *

If this method returns true, meaning we're running on a CI environment, no new snapshots are - * created and an error is thrown instead to prevent tests from silently passing when snapshots - * are not found. - * - *

Often to determine if running on a CI environment is to check for the presence of a 'CI' env - * variable - * - * @return boolean indicating if we're running on a CI environment or not - */ - boolean isCI(); -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java deleted file mode 100644 index 9054935..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java +++ /dev/null @@ -1,12 +0,0 @@ -package au.com.origin.snapshots.exceptions; - -public class LogGithubIssueException extends RuntimeException { - - private static final String LOG_SUPPORT_TICKET = - "\n\n*** This exception should never be thrown ***\n" - + "Log a support ticket at https://github.com/origin-energy/java-snapshot-testing/issues with details of the exception\n"; - - public LogGithubIssueException(String message) { - super(message + LOG_SUPPORT_TICKET); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java deleted file mode 100644 index 6504d6c..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java +++ /dev/null @@ -1,8 +0,0 @@ -package au.com.origin.snapshots.exceptions; - -public class MissingSnapshotPropertiesKeyException extends RuntimeException { - - public MissingSnapshotPropertiesKeyException(String key) { - super("\"snapshot.properties\" is missing required key=" + key); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java deleted file mode 100644 index 61a20d2..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java +++ /dev/null @@ -1,18 +0,0 @@ -package au.com.origin.snapshots.exceptions; - -import java.util.List; -import java.util.stream.Collectors; - -public class ReservedWordException extends RuntimeException { - - public ReservedWordException(String message) { - super(message); - } - - public ReservedWordException(String element, String reservedWord, List reservedWords) { - super( - String.format( - "You cannot use the '%s' character inside '%s'. Reserved characters are ", - reservedWord, element, reservedWords.stream().collect(Collectors.joining(",")))); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java deleted file mode 100644 index d8050b2..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java +++ /dev/null @@ -1,12 +0,0 @@ -package au.com.origin.snapshots.exceptions; - -public class SnapshotExtensionException extends RuntimeException { - - public SnapshotExtensionException(String message) { - super(message); - } - - public SnapshotExtensionException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java deleted file mode 100644 index 66bfd20..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java +++ /dev/null @@ -1,20 +0,0 @@ -package au.com.origin.snapshots.exceptions; - -import java.util.Collections; -import java.util.List; -import org.opentest4j.MultipleFailuresError; - -public class SnapshotMatchException extends MultipleFailuresError { - - public SnapshotMatchException(String message) { - super(message, Collections.emptyList()); - } - - public SnapshotMatchException(String message, Throwable cause) { - super(message, Collections.singletonList(cause)); - } - - public SnapshotMatchException(String message, List causes) { - super(message, causes); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java deleted file mode 100644 index b3978ae..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java +++ /dev/null @@ -1,13 +0,0 @@ -package au.com.origin.snapshots.logging; - -import org.slf4j.Logger; - -public class LoggingHelper { - - public static void deprecatedV5(Logger log, String message) { - log.warn( - "\n\n** Deprecation Warning **\nThis feature will be removed in version 5.X\n" - + message - + "\n\n"); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java deleted file mode 100644 index dbe718b..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java +++ /dev/null @@ -1,40 +0,0 @@ -package au.com.origin.snapshots.reporters.v1; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import java.util.Arrays; -import java.util.function.Supplier; -import org.assertj.core.util.diff.DiffUtils; -import org.assertj.core.util.diff.Patch; -import org.opentest4j.AssertionFailedError; - -public class PlainTextSnapshotReporter implements SnapshotReporter { - - private static final Supplier NO_DIFF_EXCEPTION_SUPPLIER = - () -> - new IllegalStateException( - "No differences found. Potential mismatch between comparator and reporter"); - - public static String getDiffString(Patch patch) { - return patch.getDeltas().stream() - .map(delta -> delta.toString() + "\n") - .reduce(String::concat) - .orElseThrow(NO_DIFF_EXCEPTION_SUPPLIER); - } - - @Override - public boolean supportsFormat(String outputFormat) { - return true; // always true - } - - @Override - public void report(Snapshot previous, Snapshot current) { - Patch patch = - DiffUtils.diff( - Arrays.asList(previous.raw().split("\n")), Arrays.asList(current.raw().split("\n"))); - - String message = "Error on: \n" + current.raw() + "\n\n" + getDiffString(patch); - - throw new AssertionFailedError(message, previous.raw(), current.raw()); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java deleted file mode 100644 index 41ed117..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java +++ /dev/null @@ -1,35 +0,0 @@ -package au.com.origin.snapshots.serializers.v1; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.nio.charset.StandardCharsets; -import java.util.Base64; - -/** - * This Serializer converts a byte[] into a base64 encoded string. If the input is not a byte[] it - * will be converted using `.getBytes(StandardCharsets.UTF_8)` method - */ -public class Base64SnapshotSerializer implements SnapshotSerializer { - private static final ToStringSnapshotSerializer toStringSnapshotSerializer = - new ToStringSnapshotSerializer(); - - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - if (object == null) { - toStringSnapshotSerializer.apply("", gen); - } - byte[] bytes = - object instanceof byte[] - ? (byte[]) object - : object.toString().getBytes(StandardCharsets.UTF_8); - String encoded = Base64.getEncoder().encodeToString(bytes); - return toStringSnapshotSerializer.apply(encoded, gen); - } - - @Override - public String getOutputFormat() { - return SerializerType.BASE64.name(); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java deleted file mode 100644 index 61e5075..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -package au.com.origin.snapshots.serializers.v1; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotFile; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import lombok.extern.slf4j.Slf4j; - -/** - * This Serializer does a snapshot of the {@link Object#toString()} method - * - *

Will render each toString() on a separate line - */ -@Slf4j -public class ToStringSnapshotSerializer implements SnapshotSerializer { - - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - String body = "[\n" + object.toString() + "\n]"; - if (body.contains(SnapshotFile.SPLIT_STRING)) { - log.warn( - "Found 3 consecutive lines in your snapshot \\n\\n\\n. This sequence is reserved as the snapshot separator - replacing with \\n.\\n.\\n"); - body = body.replaceAll(SnapshotFile.SPLIT_STRING, "\n.\n.\n"); - } - return gen.toSnapshot(body); - } - - @Override - public String getOutputFormat() { - return SerializerType.TEXT.name(); - } -} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java b/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java deleted file mode 100644 index 2f5b78b..0000000 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -package au.com.origin.snapshots.utils; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Optional; -import java.util.function.Predicate; -import lombok.experimental.UtilityClass; - -@UtilityClass -public class ReflectionUtils { - - /** - * Find {@link Field} by given predicate. - * - *

Invoke the given predicate on all fields in the target class, going up the class hierarchy - * to get all declared fields. - * - * @param clazz the target class to analyze - * @param predicate the predicate - * @return the field or empty optional - */ - public static Optional findFieldByPredicate( - final Class clazz, final Predicate predicate) { - Class targetClass = clazz; - - do { - final Field[] fields = targetClass.getDeclaredFields(); - for (final Field field : fields) { - if (!predicate.test(field)) { - continue; - } - return Optional.of(field); - } - targetClass = targetClass.getSuperclass(); - } while (targetClass != null && targetClass != Object.class); - - return Optional.empty(); - } - - public static void makeAccessible(final Field field) { - if ((!Modifier.isPublic(field.getModifiers()) - || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) - || Modifier.isFinal(field.getModifiers())) - && !field.isAccessible()) { - field.setAccessible(true); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java deleted file mode 100644 index 5e7b74a..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -public class CustomFolderSnapshotTest { - - private static final String OUTPUT_FILE = - "src/test/some-folder/au/com/origin/snapshots/__snapshots__/CustomFolderSnapshotTest.snap"; - - @BeforeEach - public void beforeEach() throws IOException { - Path path = Paths.get(OUTPUT_FILE); - Files.deleteIfExists(path); - } - - @Test - void shouldBeAbleToChangeSnapshotFolder(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new CustomFolderSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(FakeObject.builder().id("shouldBeAbleToChangeSnapshotFolder").build()); - snapshotVerifier.validateSnapshots(); - - Path path = Paths.get(OUTPUT_FILE); - Assertions.assertThat(Files.exists(path)); - } - - @Test - void shouldBeAbleToChangeSnapshotFolderLegacyTrailginSlash(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new CustomFolderSnapshotConfigLegacy(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(FakeObject.builder().id("shouldBeAbleToChangeSnapshotFolder").build()); - snapshotVerifier.validateSnapshots(); - - Path path = Paths.get(OUTPUT_FILE); - Assertions.assertThat(Files.exists(path)); - } - - public static class CustomFolderSnapshotConfig extends BaseSnapshotConfig { - - @Override - public String getOutputDir() { - return "src/test/some-folder"; - } - } - - public static class CustomFolderSnapshotConfigLegacy extends BaseSnapshotConfig { - - @Override - public String getOutputDir() { - return "src/test/some-folder/"; - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java deleted file mode 100644 index afdad05..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import lombok.SneakyThrows; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -class DebugSnapshotLineEndingsTest { - private static final SnapshotConfig CONFIG = - new BaseSnapshotConfig() { - @Override - public SnapshotSerializer getSerializer() { - return new MultiLineSnapshotSerializer(); - } - }; - private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap.debug"; - private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap"; - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - } - - @SneakyThrows - @BeforeEach - void beforeEach() { - Files.deleteIfExists(Paths.get(DEBUG_FILE_PATH)); - } - - /** - * Scenario: - An existing snapshot file checked out from git will have CR LF line endings on - * Windows OS - A newly created snapshot file will have LF line endings on any OS (see - * MultiLineSnapshotSerializer) Expectation: - As snapshot file content is identical (except for - * line endings), the debug file should not be created - */ - @DisplayName( - "Debug file should not be created when snapshots match the existing snapshot regardless of line endings") - @Test - void existingSnapshotDifferentLineEndings(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); - - SnapshotVerifier snapshotVerifier = new SnapshotVerifier(CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(Arrays.asList("a", "b")); - snapshotVerifier.validateSnapshots(); - - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH)), "Debug file should not be created"); - } - - private static class MultiLineSnapshotSerializer implements SnapshotSerializer { - @Override - public String getOutputFormat() { - return SerializerType.TEXT.name(); - } - - @Override - public Snapshot apply(Object object, SnapshotSerializerContext snapshotSerializerContext) { - Object body = - "[\n" - + Arrays.asList(object).stream() - .flatMap( - o -> { - if (o instanceof Collection) { - return ((Collection) o).stream(); - } - return Stream.of(o); - }) - .map(Object::toString) - .collect(Collectors.joining("\n")) - + "\n]"; - - return Snapshot.builder() - .name( - "au.com.origin.snapshots.DebugSnapshotLineEndingsTest.existingSnapshotDifferentLineEndings") - .body(body.toString()) - .build(); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java deleted file mode 100644 index 2934f7c..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; -import java.nio.file.Files; -import java.nio.file.Paths; -import lombok.SneakyThrows; -import org.junit.jupiter.api.*; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -public class DebugSnapshotTest { - - private static final SnapshotConfig DEFAULT_CONFIG = - new BaseSnapshotConfig() { - @Override - public SnapshotSerializer getSerializer() { - return new ToStringSnapshotSerializer(); - } - }; - - private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotTest.snap.debug"; - private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotTest.snap"; - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - } - - @SneakyThrows - @BeforeEach - public void beforeEach() { - Files.deleteIfExists(Paths.get(DEBUG_FILE_PATH)); - } - - @DisplayName("Debug file should be created when snapshots don't match") - @Test - void createDebugFile(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); - assertThrows(SnapshotMatchException.class, () -> expect.toMatchSnapshot(new TestObjectBad())); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); - } - - @DisplayName("Debug file should be created when snapshots match for a new snapshot") - @Test - void debugFileCreatedNewSnapshot(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); - expect.toMatchSnapshot(new TestObjectGood()); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); - } - - @DisplayName("Debug file should be created when snapshots match for an existing snapshot") - @Test - void debugFileCreatedExistingSnapshot(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); - expect.toMatchSnapshot(new TestObjectGood()); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); - } - - @SneakyThrows - @DisplayName("Existing debug file should not be deleted once snapshots match") - @Test - void debugFileCreatedSnapshotMatch(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - Files.createFile(Paths.get(DEBUG_FILE_PATH)); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(new TestObjectGood()); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); - } - - private static class TestObjectBad { - @Override - public String toString() { - return "Bad Snapshot"; - } - } - - private static class TestObjectGood { - @Override - public String toString() { - return "Good Snapshot"; - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java deleted file mode 100644 index db94093..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import au.com.origin.snapshots.config.ToStringSnapshotConfig; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.jupiter.api.*; - -public class EmptySnapshotFileTest { - - private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest.snap"; - private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug"; - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - } - - @DisplayName("Should remove empty snapshots") - @Test - public void shouldRemoveEmptySnapshots(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new ToStringSnapshotConfig(), testInfo.getTestClass().get()); - snapshotVerifier.validateSnapshots(); - - assertTrue(Files.notExists(Paths.get(SNAPSHOT_FILE_PATH))); - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); - } - - @Nested - public class NestedClass { - - private static final String SNAPSHOT_FILE_PATH_NESTED = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap"; - private static final String DEBUG_FILE_PATH_NESTED = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug"; - - @DisplayName("Should remove empty nested snapshots") - @Test - public void shouldRemoveEmptyNestedSnapshots(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH_NESTED))); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH_NESTED))); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new ToStringSnapshotConfig(), testInfo.getTestClass().get()); - snapshotVerifier.validateSnapshots(); - - assertTrue(Files.notExists(Paths.get(SNAPSHOT_FILE_PATH_NESTED))); - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH_NESTED))); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java deleted file mode 100644 index 1d8eea5..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import au.com.origin.snapshots.config.ToStringSnapshotConfig; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -public class EqualDebugSnapshotFileTest { - - private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap"; - private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug"; - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - } - - @DisplayName("Should remove equal debug snapshots") - @Test - public void shouldRemoveEmptySnapshots(TestInfo testInfo) { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new ToStringSnapshotConfig(), testInfo.getTestClass().get()); - snapshotVerifier.validateSnapshots(); - - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java deleted file mode 100644 index a684d55..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java +++ /dev/null @@ -1,25 +0,0 @@ -package au.com.origin.snapshots; - -import java.util.List; -import lombok.*; - -@ToString -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class FakeObject { - - private String id; - - private Integer value; - - private String name; - - @Setter private FakeObject fakeObject; - - public void fakeMethod(String fakeName, Long fakeNumber, List fakeList) {} - - public void fakeMethodWithComplexObject(Object fakeObj) {} - - public void fakeMethodWithComplexFakeObject(FakeObject fakeObj) {} -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java deleted file mode 100644 index 3fade4f..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package au.com.origin.snapshots; - -import static org.assertj.core.api.Assertions.assertThat; - -import au.com.origin.snapshots.comparators.PlainTextEqualsComparator; -import au.com.origin.snapshots.reporters.PlainTextSnapshotReporter; -import au.com.origin.snapshots.serializers.Base64SnapshotSerializer; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; -import org.junit.jupiter.api.Test; - -/** - * These classes are likely defined in snapshot.properties as a string. - * - *

The clients IDE will not complain if they change so ensure they don't - */ -public class NoNameChangeTest { - - @Test - public void serializersApiShouldNotChange() { - assertThat(Base64SnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.serializers.Base64SnapshotSerializer"); - assertThat(ToStringSnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.serializers.ToStringSnapshotSerializer"); - assertThat(SerializerType.class.getName()) - .isEqualTo("au.com.origin.snapshots.serializers.SerializerType"); - } - - @Test - public void reportersApiShouldNotChange() { - assertThat(PlainTextSnapshotReporter.class.getName()) - .isEqualTo("au.com.origin.snapshots.reporters.PlainTextSnapshotReporter"); - } - - @Test - public void comparatorsApiShouldNotChange() { - assertThat(PlainTextEqualsComparator.class.getName()) - .isEqualTo("au.com.origin.snapshots.comparators.PlainTextEqualsComparator"); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java deleted file mode 100644 index a1c1a44..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package au.com.origin.snapshots; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -public class OnLoadSnapshotFileTest { - - private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/OnLoadSnapshotFileTest.snap"; - private final SnapshotConfig CUSTOM_SNAPSHOT_CONFIG = new BaseSnapshotConfig(); - - @BeforeAll - static void beforeAll() throws IOException { - Files.deleteIfExists(Paths.get(SNAPSHOT_FILE_PATH)); - String snapshotFileContent = - "au.com.origin.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" - + "any special characters that need correct encoding äöüèéàè\n" - + "]"; - createSnapshotFile(snapshotFileContent); - } - - @DisplayName("Should load snapshots with correct encoding") - @Test - public void shouldLoadFileWithCorrectEncodingForCompare(TestInfo testInfo) throws IOException { - assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(CUSTOM_SNAPSHOT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect - .serializer(ToStringSnapshotSerializer.class) - .toMatchSnapshot("any special characters that need correct encoding äöüèéàè"); - snapshotVerifier.validateSnapshots(); - - File f = new File(SNAPSHOT_FILE_PATH); - assertThat(String.join("\n", Files.readAllLines(f.toPath()))) - .isEqualTo( - "au.com.origin.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" - + "any special characters that need correct encoding äöüèéàè\n" - + "]"); - } - - private static void createSnapshotFile(String snapshot) { - try { - File file = new File(SNAPSHOT_FILE_PATH); - file.getParentFile().mkdirs(); - file.createNewFile(); - try (FileOutputStream fileStream = new FileOutputStream(file, false)) { - fileStream.write(snapshot.getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - e.printStackTrace(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java deleted file mode 100644 index 94533b8..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package au.com.origin.snapshots; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -public class OrphanSnapshotTest { - - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - } - - @DisplayName("should fail the build when failOnOrphans=true") - @Test - void orphanSnapshotsShouldFailTheBuild(TestInfo testInfo) throws IOException { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get(), true); - FakeObject fakeObject1 = FakeObject.builder().id("anyId1").value(1).name("anyName1").build(); - final Path snapshotFile = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/OrphanSnapshotTest.snap"); - - long bytesBefore = Files.size(snapshotFile); - - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(fakeObject1); - - Throwable exceptionThatWasThrown = - assertThrows( - SnapshotMatchException.class, - () -> { - snapshotVerifier.validateSnapshots(); - }); - - assertThat(exceptionThatWasThrown.getMessage()).isEqualTo("ERROR: Found orphan snapshots"); - - // Ensure file has not changed - long bytesAfter = Files.size(snapshotFile); - assertThat(bytesAfter).isGreaterThan(bytesBefore); - } - - @DisplayName("should not fail the build when failOnOrphans=false") - @Test - void orphanSnapshotsShouldNotFailTheBuild(TestInfo testInfo) throws IOException { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get(), false); - FakeObject fakeObject1 = FakeObject.builder().id("anyId1").value(1).name("anyName1").build(); - final Path snapshotFile = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/OrphanSnapshotTest.snap"); - - long bytesBefore = Files.size(snapshotFile); - - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(fakeObject1); - - snapshotVerifier.validateSnapshots(); - - // Ensure file has not changed - long bytesAfter = Files.size(snapshotFile); - assertThat(bytesAfter).isGreaterThan(bytesBefore); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java deleted file mode 100644 index 99ee602..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -class PrivateCalledMethodTest { - - @Test - void testName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - testBasedOnArgs("testContent", testInfo); - snapshotVerifier.validateSnapshots(); - } - - private void testBasedOnArgs(String arg, TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(arg); - snapshotVerifier.validateSnapshots(); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java deleted file mode 100644 index 0fe0100..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java +++ /dev/null @@ -1,30 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import java.lang.reflect.Method; -import java.util.Optional; -import java.util.stream.Stream; - -public class ReflectionUtilities { - - // FIXME consider guava reflection instead - public static Method getMethod(Class clazz, String methodName) { - try { - return Stream.of(clazz.getDeclaredMethods()) - .filter(method -> method.getName().equals(methodName)) - .findFirst() - .orElseThrow(() -> new NoSuchMethodException("Not Found")); - } catch (NoSuchMethodException e) { - return Optional.ofNullable(clazz.getSuperclass()) - .map(superclass -> getMethod(superclass, methodName)) - .orElseThrow( - () -> - new SnapshotMatchException( - "Could not find method " - + methodName - + " on class " - + clazz - + "\nPlease annotate your test method with @Test and make it without any parameters!")); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java deleted file mode 100644 index 3bff448..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -class ScenarioTest { - - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - - @Test - void canTakeMultipleSnapshotsUsingScenario(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Default Snapshot"); - expect.scenario("additional").toMatchSnapshot("Additional Snapshot"); - snapshotVerifier.validateSnapshots(); - } - - @Test - void canTakeTheSameSnapshotTwice(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Default Snapshot"); - expect.toMatchSnapshot("Default Snapshot"); - expect.scenario("scenario").toMatchSnapshot("Scenario Snapshot"); - expect.scenario("scenario").toMatchSnapshot("Scenario Snapshot"); - snapshotVerifier.validateSnapshots(); - } - - @Test - void cannotTakeDifferentSnapshotsAtDefaultLevel(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Default Snapshot"); - assertThrows(SnapshotMatchException.class, () -> expect.toMatchSnapshot("Default Snapshot 2")); - } - - @Test - void cannotTakeDifferentSnapshotsAtScenarioLevel(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.scenario("scenario").toMatchSnapshot("Default Snapshot"); - assertThrows( - SnapshotMatchException.class, - () -> expect.scenario("scenario").toMatchSnapshot("Default Snapshot 2")); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java deleted file mode 100644 index 25872f0..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java +++ /dev/null @@ -1,104 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; - -class SnapshotCaptor { - - private Class parameterClass; - - private Class argumentClass; - - private String[] ignore; - - public SnapshotCaptor(Class parameterClass, String... ignore) { - this.parameterClass = parameterClass; - this.argumentClass = parameterClass; - this.ignore = ignore; - } - - public SnapshotCaptor(Class parameterClass, Class argumentClass, String... ignore) { - this.parameterClass = parameterClass; - this.argumentClass = argumentClass; - this.ignore = ignore; - } - - public Class getParameterClass() { - return parameterClass; - } - - public Object removeIgnored(Object value) { - Object newValue = value; - if (ignore != null && ignore.length > 0) { - newValue = shallowCopy(value); - for (String each : ignore) { - try { - Field field = this.argumentClass.getDeclaredField(each); - field.setAccessible(true); - if (field.getType().isPrimitive()) { - field.setByte(newValue, Integer.valueOf(0).byteValue()); - } else { - field.set(newValue, null); - } - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new SnapshotExtensionException("Invalid Ignore value " + each, e.getCause()); - } - } - } - return newValue; - } - - private Object shallowCopy(Object value) { - try { - Object newValue = constructCopy(this.argumentClass); - - Field[] fields = this.argumentClass.getDeclaredFields(); - - for (Field field : fields) { - field.setAccessible(true); - try { - field.set(newValue, field.get(value)); - } catch (Exception e) { - // ignore - } - } - return newValue; - } catch (Exception e) { - throw new SnapshotExtensionException( - "Class " - + this.argumentClass.getSimpleName() - + " must have a default empty constructor!"); - } - } - - private Object constructCopy(Class argumentClass) - throws InstantiationException, IllegalAccessException, - java.lang.reflect.InvocationTargetException, NoSuchMethodException { - - try { - return argumentClass.getDeclaredConstructor().newInstance(); - } catch (Exception e) { - // Ignore - should log - } - - Constructor[] constructors = argumentClass.getDeclaredConstructors(); - - if (constructors.length == 0) { - return argumentClass.getDeclaredConstructor().newInstance(); - } - - int i = 0; - Class[] types = constructors[i].getParameterTypes(); - Object[] paramValues = new Object[types.length]; - - for (int j = 0; j < types.length; j++) { - if (types[j].isPrimitive()) { - paramValues[j] = Integer.valueOf(0).byteValue(); - } else { - paramValues[j] = constructCopy(types[j]); - } - } - return constructors[i].newInstance(paramValues); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java deleted file mode 100644 index 550514a..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java +++ /dev/null @@ -1,230 +0,0 @@ -package au.com.origin.snapshots; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import lombok.SneakyThrows; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.opentest4j.AssertionFailedError; - -@ExtendWith(MockitoExtension.class) -class SnapshotContextTest { - - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - private static final String FILE_PATH = "src/test/java/anyFilePath"; - private static final String SNAPSHOT_NAME = "java.lang.String.toString"; - private static final String SNAPSHOT = "java.lang.String.toString=[\nanyObject\n]"; - - private SnapshotFile snapshotFile; - - private SnapshotContext snapshotContext; - - @BeforeEach - void setUp() throws NoSuchMethodException, IOException { - snapshotFile = - new SnapshotFile(DEFAULT_CONFIG.getOutputDir(), "anyFilePath", SnapshotContextTest.class); - snapshotContext = - new SnapshotContext( - DEFAULT_CONFIG, - snapshotFile, - String.class, - String.class.getDeclaredMethod("toString"), - "anyObject"); - } - - @AfterEach - void tearDown() throws IOException { - Files.deleteIfExists(Paths.get(FILE_PATH)); - } - - @Test - void shouldGetSnapshotNameSuccessfully() { - String snapshotName = snapshotContext.resolveSnapshotIdentifier(); - assertThat(snapshotName).isEqualTo(SNAPSHOT_NAME); - } - - @Test - void shouldMatchSnapshotSuccessfully() { - snapshotContext.toMatchSnapshot(); - assertThat(snapshotFile.getSnapshots().stream().findFirst().get().raw()).isEqualTo(SNAPSHOT); - } - - @Test - void shouldMatchSnapshotWithException() { - snapshotFile.pushSnapshot(Snapshot.parse(SNAPSHOT_NAME + "=anyWrongSnapshot")); - assertThrows(SnapshotMatchException.class, snapshotContext::toMatchSnapshot); - } - - @SneakyThrows - @Test - void shouldRenderScenarioNameWhenSupplied() { - SnapshotContext snapshotContextWithScenario = - new SnapshotContext( - DEFAULT_CONFIG, - snapshotFile, - String.class, - String.class.getDeclaredMethod("toString"), - "anyObject"); - snapshotContextWithScenario.setScenario("hello world"); - assertThat(snapshotContextWithScenario.resolveSnapshotIdentifier()) - .isEqualTo("java.lang.String.toString[hello world]"); - } - - @SneakyThrows - @Test - void shouldNotRenderScenarioNameWhenNull() { - SnapshotContext snapshotContextWithoutScenario = - new SnapshotContext( - DEFAULT_CONFIG, - snapshotFile, - String.class, - String.class.getDeclaredMethod("toString"), - "anyObject"); - assertThat(snapshotContextWithoutScenario.resolveSnapshotIdentifier()) - .isEqualTo("java.lang.String.toString"); - } - - @SneakyThrows - @Test - void shouldOverwriteSnapshotsWhenParamIsPassed() { - SnapshotConfig mockConfig = Mockito.mock(SnapshotConfig.class); - Mockito.when(mockConfig.updateSnapshot()).thenReturn(Optional.of("")); - Mockito.when(mockConfig.getSerializer()).thenReturn(new ToStringSnapshotSerializer()); - SnapshotFile snapshotFile = Mockito.mock(SnapshotFile.class); - Set set = new HashSet<>(); - set.add(Snapshot.parse("java.lang.String.toString[hello world]=[{" + "\"a\": \"b\"" + "}]")); - Mockito.when(snapshotFile.getSnapshots()).thenReturn(set); - - SnapshotContext snapshotContext = - new SnapshotContext( - mockConfig, - snapshotFile, - String.class, - String.class.getDeclaredMethod("toString"), - "anyObject"); - snapshotContext.setScenario("hello world"); - snapshotContext.toMatchSnapshot(); - Mockito.verify(snapshotFile) - .pushSnapshot(Snapshot.parse("java.lang.String.toString[hello world]=[\nanyObject\n]")); - } - - @SneakyThrows - @Test - void shouldFailWhenRunningOnCiWithoutExistingSnapshot() { - BaseSnapshotConfig ciSnapshotConfig = - new BaseSnapshotConfig() { - @Override - public boolean isCI() { - return true; - } - }; - - SnapshotContext ciSnapshotContext = - new SnapshotContext( - ciSnapshotConfig, - new SnapshotFile(ciSnapshotConfig.getOutputDir(), "blah", SnapshotContextTest.class), - String.class, - String.class.getDeclaredMethod("toString"), - "anyObject"); - - Assertions.assertThatThrownBy(ciSnapshotContext::toMatchSnapshot) - .hasMessage( - "Snapshot [java.lang.String.toString] not found. Has this snapshot been committed ?"); - } - - @SneakyThrows - @Test - void shouldAggregateMultipleFailures() { - SnapshotFile snapshotFile = Mockito.mock(SnapshotFile.class); - Set set = new HashSet<>(); - set.add(Snapshot.parse("java.lang.String.toString=[\n \"hello\"\n]")); - Mockito.when(snapshotFile.getSnapshots()).thenReturn(set); - - Stream> reportingFunctions = - Stream.of( - (rawSnapshot, currentObject) -> - assertThat(currentObject).isEqualTo(rawSnapshot), // assertj - org.junit.jupiter.api.Assertions::assertEquals, // junit jupiter - (previous, current) -> { - String message = - String.join( - System.lineSeparator(), - "Expected : ", - previous.raw(), - "Actual : ", - current.raw()); - throw new AssertionFailedError(message, previous, current); // opentest4j - }); - - Stream reporters = - reportingFunctions.map( - consumer -> - new SnapshotReporter() { - @Override - public boolean supportsFormat(String outputFormat) { - return true; - } - - @Override - public void report(Snapshot previous, Snapshot current) { - consumer.accept(previous, current); - } - }); - - SnapshotContext failingSnapshotContext = - new SnapshotContext( - DEFAULT_CONFIG, - snapshotFile, - String.class, - String.class.getDeclaredMethod("toString"), - "hola"); - failingSnapshotContext.setSnapshotSerializer(new ToStringSnapshotSerializer()); - failingSnapshotContext.setSnapshotReporters(reporters.collect(Collectors.toList())); - - try { - failingSnapshotContext.toMatchSnapshot(); - } catch (Throwable m) { - String cleanMessage = - m.getMessage() - .replace("<\"", "") - .replace("<", "") - .replaceAll("\n", "") - .replaceAll("\r", "") - .replaceAll("\t", "") - .replace("\">", " ") - .replace(">", " ") - .replace("]", "") - .replace("java.lang.String.toString=[", "") - .replaceAll(" +", " "); - - assertThat(cleanMessage) - .containsPattern("Expecting.*hola.*to be equal to.*hello.*but was not"); // assertj - assertThat(cleanMessage).containsPattern("expected.*hello.*but was.*hola"); // junit jupiter - assertThat(cleanMessage).containsPattern("Expected.*hello.*Actual.*hola"); // opentest4j - - return; - } - - Assertions.fail("Expected an error to be thrown"); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java deleted file mode 100644 index 1f0b13b..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java +++ /dev/null @@ -1,59 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.LowercaseToStringSerializer; -import au.com.origin.snapshots.serializers.SerializerType; -import lombok.NoArgsConstructor; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -public class SnapshotHeaders { - - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - - static SnapshotVerifier snapshotVerifier; - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - snapshotVerifier = new SnapshotVerifier(DEFAULT_CONFIG, SnapshotHeaders.class); - } - - @AfterAll - static void afterAll() { - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldBeAbleToSnapshotASingleCustomHeader(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer(CustomHeadersSerializer.class).toMatchSnapshot("Hello World"); - } - - @Test - void shouldBeAbleToSnapshotMultipleCustomHeader(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer(CustomHeadersSerializer.class).toMatchSnapshot("Hello World"); - } - - @NoArgsConstructor - private static class CustomHeadersSerializer extends LowercaseToStringSerializer { - @Override - public String getOutputFormat() { - return SerializerType.JSON.name(); - } - - @Override - public Snapshot apply(Object object, SnapshotSerializerContext snapshotSerializerContext) { - snapshotSerializerContext.getHeader().put("custom", "anything"); - snapshotSerializerContext.getHeader().put("custom2", "anything2"); - return super.apply(object, snapshotSerializerContext); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java deleted file mode 100644 index 22d255a..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.serializers.UppercaseToStringSerializer; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -public class SnapshotIntegrationTest { - - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - - static SnapshotVerifier snapshotVerifier; - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - snapshotVerifier = new SnapshotVerifier(DEFAULT_CONFIG, SnapshotIntegrationTest.class); - } - - @AfterAll - static void afterAll() { - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldMatchSnapshotOne(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(FakeObject.builder().id("anyId1").value(1).name("anyName1").build()); - } - - @Test - void shouldMatchSnapshotTwo(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(FakeObject.builder().id("anyId2").value(2).name("anyName2").build()); - } - - @Test - void shouldMatchSnapshotThree(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(FakeObject.builder().id("anyId3").value(3).name("anyName3").build()); - } - - @Test - void shouldMatchSnapshotFour(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot( - FakeObject.builder().id("anyId4").value(4).name("any\n\n\nName4").build()); - } - - @Test - void shouldMatchSnapshotInsidePrivateMethod(TestInfo testInfo) { - matchInsidePrivate(testInfo); - } - - @Test - void shouldThrowSnapshotMatchException(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows( - SnapshotMatchException.class, - () -> - expect.toMatchSnapshot( - FakeObject.builder().id("anyId5").value(6).name("anyName5").build()), - "Error on: \n" - + "au.com.origin.snapshots.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=["); - } - - @Test - void shouldSnapshotUsingSerializerClass(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer(UppercaseToStringSerializer.class).toMatchSnapshot("Hello World"); - } - - @Test - void shouldSnapshotUsingSerializerPropertyName(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer("lowercase").toMatchSnapshot("Hello World"); - } - - private void matchInsidePrivate(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot( - FakeObject.builder().id("anyPrivate").value(5).name("anyPrivate").build()); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java deleted file mode 100644 index ab45e39..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package au.com.origin.snapshots; - -import static org.assertj.core.api.Assertions.assertThat; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class SnapshotMatcherScenarioTest { - - private static final String FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotMatcherScenarioTest.snap"; - - static SnapshotVerifier snapshotVerifier; - - @BeforeAll - static void beforeAll() { - snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), SnapshotMatcherScenarioTest.class); - } - - @AfterAll - static void afterAll() throws IOException { - snapshotVerifier.validateSnapshots(); - File f = new File(FILE_PATH); - assertThat(String.join("\n", Files.readAllLines(f.toPath()))) - .isEqualTo( - "au.com.origin.snapshots.SnapshotMatcherScenarioTest.should1ShowSnapshotSuccessfully[Scenario A]=[\n" - + "any type of object\n" - + "]\n\n\n" - + "au.com.origin.snapshots.SnapshotMatcherScenarioTest.should2SecondSnapshotExecutionSuccessfully[Scenario B]=[\n" - + "any second type of object\n" - + "]"); - Files.delete(Paths.get(FILE_PATH)); - } - - @Test - void should1ShowSnapshotSuccessfully(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.scenario("Scenario A").toMatchSnapshot("any type of object"); - File f = new File(FILE_PATH); - if (!f.exists() || f.isDirectory()) { - throw new RuntimeException("File should exist here"); - } - } - - @Test - void should2SecondSnapshotExecutionSuccessfully(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.scenario("Scenario B").toMatchSnapshot("any second type of object"); - File f = new File(FILE_PATH); - if (!f.exists() || f.isDirectory()) { - throw new RuntimeException("File should exist here"); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java deleted file mode 100644 index 3cfcfbe..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package au.com.origin.snapshots; - -import static org.assertj.core.api.Assertions.assertThat; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class SnapshotMatcherTest { - - private static final String FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotMatcherTest.snap"; - - static SnapshotVerifier snapshotVerifier; - - @BeforeAll - static void beforeAll() { - snapshotVerifier = new SnapshotVerifier(new BaseSnapshotConfig(), SnapshotMatcherTest.class); - } - - @AfterAll - static void afterAll() throws IOException { - snapshotVerifier.validateSnapshots(); - File f = new File(FILE_PATH); - assertThat(String.join("\n", Files.readAllLines(f.toPath()))) - .isEqualTo( - "au.com.origin.snapshots.SnapshotMatcherTest.should1ShowSnapshotSuccessfully=[\n" - + "any type of object\n" - + "]\n\n\n" - + "au.com.origin.snapshots.SnapshotMatcherTest.should2SecondSnapshotExecutionSuccessfully=[\n" - + "any second type of object\n" - + "]"); - Files.delete(Paths.get(FILE_PATH)); - } - - @Test - void should1ShowSnapshotSuccessfully(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("any type of object"); - File f = new File(FILE_PATH); - if (!f.exists() || f.isDirectory()) { - throw new RuntimeException("File should exist here"); - } - } - - @Test - void should2SecondSnapshotExecutionSuccessfully(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("any second type of object"); - File f = new File(FILE_PATH); - if (!f.exists() || f.isDirectory()) { - throw new RuntimeException("File should exist here"); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java deleted file mode 100644 index e8740ab..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.exceptions.ReservedWordException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -public class SnapshotNameAnnotationTest { - - @BeforeEach - void beforeEach() { - SnapshotUtils.copyTestSnapshots(); - } - - @SnapshotName("can_use_snapshot_name") - @Test - void canUseSnapshotNameAnnotation(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Hello World"); - snapshotVerifier.validateSnapshots(); - } - - @SnapshotName("can use snapshot name with spaces") - @Test - void canUseSnapshotNameAnnotationWithSpaces(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Hello World"); - snapshotVerifier.validateSnapshots(); - } - - @SnapshotName("can't use '=' character in snapshot name") - @Test - void cannotUseEqualsInsideSnapshotName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows(ReservedWordException.class, () -> expect.toMatchSnapshot("FooBar")); - } - - @SnapshotName("can't use '[' character in snapshot name") - @Test - void cannotUseOpeningSquareBracketInsideSnapshotName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows(ReservedWordException.class, () -> expect.toMatchSnapshot("FooBar")); - } - - @SnapshotName("can't use ']' character in snapshot name") - @Test - void cannotUseClosingSquareBracketInsideSnapshotName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows(ReservedWordException.class, () -> expect.toMatchSnapshot("FooBar")); - } - - @Test - void cannotUseEqualsInsideScenarioName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows( - ReservedWordException.class, - () -> expect.scenario("can't use = symbol in scenario").toMatchSnapshot("FooBar")); - } - - @Test - void cannotUseOpeningSquareBracketInsideScenarioName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows( - ReservedWordException.class, - () -> expect.scenario("can't use [ symbol in scenario").toMatchSnapshot("FooBar")); - } - - @Test - void cannotUseClosingSquareBracketInsideScenarioName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows( - ReservedWordException.class, - () -> expect.scenario("can't use ] symbol in scenario").toMatchSnapshot("FooBar")); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java deleted file mode 100644 index 570f327..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -public class SnapshotNameAnnotationWithDuplicatesTest { - - @SnapshotName("hello_world") - @Test - void canUseSnapshotNameAnnotation(TestInfo testInfo) { - assertThrows( - SnapshotExtensionException.class, - () -> new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()), - "Oops, looks like you set the same name of two separate snapshots @SnapshotName(\"hello_world\") in class au.com.origin.snapshots.SnapshotNameAnnotationTest"); - } - - @SnapshotName("hello_world") - private void anotherMethodWithSameSnapshotName() {} -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java deleted file mode 100644 index 2526ef3..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; - -public class SnapshotOverrideClassTest extends SnapshotSuperClassTest { - - @BeforeEach - void beforeEach() { - snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), SnapshotOverrideClassTest.class); - } - - @AfterEach - void afterEach() { - snapshotVerifier.validateSnapshots(); - } - - @Override - public String getName() { - return "anyName"; - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java deleted file mode 100644 index 95ab048..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package au.com.origin.snapshots; - -import lombok.Getter; -import lombok.Setter; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -public abstract class SnapshotSuperClassTest { - - @Getter @Setter static SnapshotVerifier snapshotVerifier; - - public abstract String getName(); - - @Test - void shouldMatchSnapshotOne(TestInfo testInfo) { - Expect.of(snapshotVerifier, testInfo.getTestMethod().get()).toMatchSnapshot(getName()); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java deleted file mode 100644 index ba1113d..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package au.com.origin.snapshots; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -import org.junit.jupiter.api.Test; - -class SnapshotTest { - - @Test - public void shouldParseSnapshot() { - Snapshot snapshot = - Snapshot.parse( - Snapshot.builder().name("au.com.origin.snapshots.Test").body("body").build().raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getHeader()).isEmpty(); - assertThat(snapshot.getScenario()).isBlank(); - assertThat(snapshot.getBody()).isEqualTo("body"); - } - - @Test - public void shouldParseSnapshotWithHeaders() { - SnapshotHeader header = new SnapshotHeader(); - header.put("header1", "value1"); - Snapshot snapshot = - Snapshot.parse( - Snapshot.builder() - .name("au.com.origin.snapshots.Test") - .header(header) - .body("body") - .build() - .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getHeader()).containsExactly(entry("header1", "value1")); - assertThat(snapshot.getScenario()).isBlank(); - assertThat(snapshot.getBody()).isEqualTo("body"); - } - - @Test - public void shouldParseSnapshotWithScenario() { - Snapshot snapshot = - Snapshot.parse( - Snapshot.builder() - .name("au.com.origin.snapshots.Test") - .scenario("scenario") - .body("body") - .build() - .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getHeader()).isEmpty(); - assertThat(snapshot.getScenario()).isEqualTo("scenario"); - assertThat(snapshot.getBody()).isEqualTo("body"); - } - - @Test - public void shouldParseSnapshotWithScenarioAndHeaders() { - SnapshotHeader header = new SnapshotHeader(); - header.put("header1", "value1"); - Snapshot snapshot = - Snapshot.parse( - Snapshot.builder() - .name("au.com.origin.snapshots.Test") - .scenario("scenario") - .header(header) - .body("body") - .build() - .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getHeader()).containsExactly(entry("header1", "value1")); - assertThat(snapshot.getScenario()).isEqualTo("scenario"); - assertThat(snapshot.getBody()).isEqualTo("body"); - } - - @Test - public void - shouldParseSnapshotWithScenarioAndBodyWithSomethingSimilarToAnScenarioToConfuseRegex() { - Snapshot snapshot = - Snapshot.parse( - Snapshot.builder() - .name("au.com.origin.snapshots.Test") - .scenario("scenario") - .body("[xxx]=yyy") - .build() - .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getHeader()).isEmpty(); - assertThat(snapshot.getScenario()).isEqualTo("scenario"); - assertThat(snapshot.getBody()).isEqualTo("[xxx]=yyy"); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java deleted file mode 100644 index 1514cc2..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java +++ /dev/null @@ -1,105 +0,0 @@ -package au.com.origin.snapshots; - -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.verify; - -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import java.io.IOException; -import java.lang.reflect.Parameter; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import org.apache.commons.io.FileUtils; -import org.mockito.ArgumentCaptor; - -public class SnapshotUtils { - - public static HashMap>> extractArgs( - T object, String methodName, SnapshotCaptor... snapshotCaptors) { - List captors = new ArrayList<>(); - Class[] classes = new Class[snapshotCaptors.length]; - - int i = 0; - for (SnapshotCaptor snapshotCaptor : snapshotCaptors) { - classes[i] = snapshotCaptor.getParameterClass(); - captors.add(ArgumentCaptor.forClass(snapshotCaptor.getParameterClass())); - i++; - } - - return process(object, methodName, captors, classes, snapshotCaptors); - } - - public static HashMap>> extractArgs( - T object, String methodName, Class... classes) { - List captors = new ArrayList<>(); - - for (Class clazz : classes) { - captors.add(ArgumentCaptor.forClass(clazz)); - } - - return process(object, methodName, captors, classes, null); - } - - private static HashMap>> process( - T object, - String methodName, - List captors, - Class[] classes, - SnapshotCaptor[] snapshotCaptors) { - HashMap>> result = new HashMap<>(); - try { - Parameter[] parameters = - object.getClass().getDeclaredMethod(methodName, classes).getParameters(); - - object - .getClass() - .getDeclaredMethod(methodName, classes) - .invoke( - verify(object, atLeastOnce()), - captors.stream().map(ArgumentCaptor::capture).toArray()); - - List> extractedObjects = new ArrayList<>(); - - int numberOfCall; - - if (captors.size() > 0) { - numberOfCall = captors.get(0).getAllValues().size(); - - for (int i = 0; i < numberOfCall; i++) { - LinkedHashMap objectMap = new LinkedHashMap<>(); - - int j = 0; - for (ArgumentCaptor captor : captors) { - Object value = captor.getAllValues().get(i); - if (snapshotCaptors != null) { - value = snapshotCaptors[j].removeIgnored(value); - } - objectMap.put(parameters[j].getName(), value); - j++; - } - extractedObjects.add(objectMap); - } - } - - result.put( - object.getClass().getSuperclass().getSimpleName() + "." + methodName, extractedObjects); - } catch (Exception e) { - throw new SnapshotMatchException(e.getMessage(), e.getCause()); - } - - return result; - } - - public static void copyTestSnapshots() { - try { - FileUtils.copyDirectory( - Paths.get("src/test/java/au/com/origin/snapshots/existing-snapshots").toFile(), - Paths.get("src/test/java/au/com/origin/snapshots").toFile()); - } catch (IOException e) { - e.printStackTrace(); - throw new RuntimeException("Can't move files to __snapshots__ folder"); - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java deleted file mode 100644 index 91f39b7..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package au.com.origin.snapshots; - -import static au.com.origin.snapshots.SnapshotUtils.extractArgs; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import java.util.Arrays; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class SnapshotUtilsTest { - - @Mock private FakeObject fakeObject; - - @Test - void shouldExtractArgsFromFakeMethod(TestInfo testInfo) { - fakeObject.fakeMethod("test1", 1L, Arrays.asList("listTest1")); - fakeObject.fakeMethod("test2", 2L, Arrays.asList("listTest1", "listTest2")); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot( - extractArgs( - fakeObject, - "fakeMethod", - new SnapshotCaptor(String.class), - new SnapshotCaptor(Long.class), - new SnapshotCaptor(List.class))); - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldExtractArgsFromFakeMethodWithComplexObject(TestInfo testInfo) { - FakeObject fake = new FakeObject.FakeObjectBuilder().id("idMock").name("nameMock").build(); - - // With Ignore - fakeObject.fakeMethodWithComplexFakeObject(fake); - Object fakeMethodWithComplexObjectWithIgnore = - extractArgs( - fakeObject, - "fakeMethodWithComplexFakeObject", - new SnapshotCaptor(FakeObject.class, "name")); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(fakeMethodWithComplexObjectWithIgnore); - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldExtractArgsFromFakeMethodWithComplexFakeObject(TestInfo testInfo) { - - FakeObject fake = new FakeObject.FakeObjectBuilder().id("idMock").name("nameMock").build(); - - // With Ignore - fakeObject.fakeMethodWithComplexObject(fake); - Object fakeMethodWithComplexObjectWithIgnore = - extractArgs( - fakeObject, - "fakeMethodWithComplexObject", - new SnapshotCaptor(Object.class, FakeObject.class, "name")); - - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(fakeMethodWithComplexObjectWithIgnore); - snapshotVerifier.validateSnapshots(); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java deleted file mode 100644 index c6f2b92..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.*; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@Deprecated -@ExtendWith(MockitoExtension.class) -public class UpdateSnapshotPropertyTest { - - @AfterAll - static void afterAll() { - System.clearProperty(SnapshotConfig.JVM_UPDATE_SNAPSHOTS_PARAMETER); - } - - @BeforeEach - public void beforeEach() throws Exception { - File file = - new File( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap"); - String content = - "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" - + "FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null)\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" - + "FakeObject(id=ERROR, value=2, name=anyName2, fakeObject=null)\n" - + "]"; - Path parentDir = file.getParentFile().toPath(); - if (!Files.exists(parentDir)) { - Files.createDirectories(parentDir); - } - Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8)); - } - - @Test - void shouldUpdateSnapshot(TestInfo testInfo) throws IOException { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get(), false); - System.setProperty(SnapshotConfig.JVM_UPDATE_SNAPSHOTS_PARAMETER, ""); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(FakeObject.builder().id("anyId2").value(2).name("anyName2").build()); - snapshotVerifier.validateSnapshots(); - - String content = - new String( - Files.readAllBytes( - Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap")), - StandardCharsets.UTF_8); - Assertions.assertThat(content) - .isEqualTo( - "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" - + "FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null)\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" - + "FakeObject(id=anyId2, value=2, name=anyName2, fakeObject=null)\n" - + "]"); - } - - @Test - void shouldNotUpdateSnapshot(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - System.setProperty(SnapshotConfig.JVM_UPDATE_SNAPSHOTS_PARAMETER, "true"); - assertThrows( - SnapshotMatchException.class, - () -> - expect.toMatchSnapshot( - FakeObject.builder().id("anyId1").value(1).name("anyName1").build()), - "Error on: \n" - + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=["); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java deleted file mode 100644 index b999284..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java +++ /dev/null @@ -1,153 +0,0 @@ -package au.com.origin.snapshots; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -public class UpdateSnapshotTest { - - @BeforeEach - public void beforeEach() throws Exception { - File file = - new File("src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap"); - String content = - "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" - + "OLD\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" - + "OLD\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" - + "OLD\n" - + "]"; - Path parentDir = file.getParentFile().toPath(); - if (!Files.exists(parentDir)) { - Files.createDirectories(parentDir); - } - Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8)); - } - - @Test - void canUpdateAllSnapshots(TestInfo testInfo) throws IOException { - SnapshotConfig config = - new BaseSnapshotConfig() { - @Override - public Optional updateSnapshot() { - return Optional.of(""); - } - }; - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(config, testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("NEW"); - snapshotVerifier.validateSnapshots(); - - String content = - new String( - Files.readAllBytes( - Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap")), - StandardCharsets.UTF_8); - Assertions.assertThat(content) - .isEqualTo( - "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" - + "NEW\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" - + "OLD\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" - + "OLD\n" - + "]"); - } - - @Test - void canUpdateNoSnapshots(TestInfo testInfo) { - SnapshotConfig config = - new BaseSnapshotConfig() { - @Override - public Optional updateSnapshot() { - return Optional.empty(); - } - }; - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(config, testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - assertThrows(SnapshotMatchException.class, () -> expect.toMatchSnapshot("FOOBAR")); - } - - @Test - public void canUpdateNewSnapshots() { - SnapshotConfig config = - new BaseSnapshotConfig() { - @Override - public Optional updateSnapshot() { - return Optional.of("new"); - } - }; - - // TODO Pending Implementation - } - - @Test - public void canUpdateClassNameSnapshots(TestInfo testInfo) throws IOException { - SnapshotConfig config = - new BaseSnapshotConfig() { - @Override - public Optional updateSnapshot() { - return Optional.of("UpdateSnapshotTest"); - } - }; - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(config, testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("NEW"); - snapshotVerifier.validateSnapshots(); - - String content = - new String( - Files.readAllBytes( - Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap")), - StandardCharsets.UTF_8); - Assertions.assertThat(content) - .isEqualTo( - "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" - + "OLD\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" - + "NEW\n" - + "]\n" - + "\n" - + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" - + "OLD\n" - + "]"); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java deleted file mode 100644 index dea37e3..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.config.ToStringSnapshotConfig; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@UseSnapshotConfig(ToStringSnapshotConfig.class) -@ExtendWith(MockitoExtension.class) -public class UseCustomConfigTest { - - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - - @BeforeAll - static void beforeAll() { - SnapshotUtils.copyTestSnapshots(); - } - - @Test - void canUseSnapshotConfigAnnotationAtClassLevel(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(new TestObject()); - snapshotVerifier.validateSnapshots(); - } - - private class TestObject { - @Override - public String toString() { - return "This is a snapshot of the toString() method"; - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java deleted file mode 100644 index 21cc8ad..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.UppercaseToStringSerializer; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -public class UseCustomSerializerTest { - - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - - @BeforeAll - static void beforeEach() { - SnapshotUtils.copyTestSnapshots(); - } - - @DisplayName("@SnapshotSerializer on a method via new instance") - @Test - public void canUseSnapshotSerializerAnnotationAtMethodLevelUsingNewInstance(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer(new UppercaseToStringSerializer()).toMatchSnapshot(new TestObject()); - snapshotVerifier.validateSnapshots(); - } - - @DisplayName("@SnapshotSerializer on a method via class name") - @Test - public void canUseSnapshotSerializerAnnotationAtMethodLevelUsingClassName(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer(new UppercaseToStringSerializer()).toMatchSnapshot(new TestObject()); - snapshotVerifier.validateSnapshots(); - } - - private class TestObject { - @Override - public String toString() { - return "This is a snapshot of the toString() method"; - } - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java deleted file mode 100644 index a14be0e..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package au.com.origin.snapshots.comparators; - -import au.com.origin.snapshots.Snapshot; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -class PlainTextEqualsComparatorTest { - - private static final PlainTextEqualsComparator COMPARATOR = new PlainTextEqualsComparator(); - - @Test - void successfulComparison() { - Snapshot snap1 = Snapshot.builder().name("snap1").scenario("A").body("foo").build(); - Snapshot snap2 = Snapshot.builder().name("snap1").scenario("A").body("foo").build(); - Assertions.assertThat(COMPARATOR.matches(snap1, snap2)).isTrue(); - } - - @Test - void failingComparison() { - Snapshot snap1 = Snapshot.builder().name("snap1").scenario("A").body("foo").build(); - Snapshot snap2 = Snapshot.builder().name("snap1").scenario("A").body("bar").build(); - Assertions.assertThat(COMPARATOR.matches(snap1, snap2)).isFalse(); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java deleted file mode 100644 index 5e6e6a8..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -package au.com.origin.snapshots.config; - -import au.com.origin.snapshots.comparators.PlainTextEqualsComparator; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.reporters.PlainTextSnapshotReporter; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; -import java.util.Collections; -import java.util.List; - -public class BaseSnapshotConfig implements SnapshotConfig { - - @Override - public String getOutputDir() { - return "src/test/java"; - } - - @Override - public String getSnapshotDir() { - return "__snapshots__"; - } - - @Override - public SnapshotSerializer getSerializer() { - return new ToStringSnapshotSerializer(); - } - - @Override - public SnapshotComparator getComparator() { - return new PlainTextEqualsComparator(); - } - - @Override - public List getReporters() { - return Collections.singletonList(new PlainTextSnapshotReporter()); - } - - @Override - public boolean isCI() { - return false; - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java deleted file mode 100644 index 84daa1a..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package au.com.origin.snapshots.config; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; - -public class ToStringSnapshotConfig extends BaseSnapshotConfig { - - @Override - public SnapshotSerializer getSerializer() { - return new SnapshotSerializer() { - @Override - public String getOutputFormat() { - return SerializerType.TEXT.name(); - } - - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - return gen.toSnapshot(object.toString()); - } - }; - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug deleted file mode 100644 index e69de29..0000000 diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug deleted file mode 100644 index ad53cf0..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug +++ /dev/null @@ -1,13 +0,0 @@ -au.com.origin.snapshots.DebugSnapshotTest.createDebugFile=[ -Good Snapshot -] - - -au.com.origin.snapshots.DebugSnapshotTest.debugFileCreatedSnapshotMatch=[ -Good Snapshot -] - - -au.com.origin.snapshots.DebugSnapshotTest.debugFileCreatedExistingSnapshot=[ -Good Snapshot -] \ No newline at end of file diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap deleted file mode 100644 index b0128f4..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap +++ /dev/null @@ -1,13 +0,0 @@ -au.com.origin.snapshots.SnapshotUtilsTest.shouldExtractArgsFromFakeMethod=[ -{FakeObject.fakeMethod=[{arg0=test1, arg1=1, arg2=[listTest1]}, {arg0=test2, arg1=2, arg2=[listTest1, listTest2]}]} -] - - -au.com.origin.snapshots.SnapshotUtilsTest.shouldExtractArgsFromFakeMethodWithComplexFakeObject=[ -{FakeObject.fakeMethodWithComplexObject=[{arg0=FakeObject(id=idMock, value=null, name=null, fakeObject=null)}]} -] - - -au.com.origin.snapshots.SnapshotUtilsTest.shouldExtractArgsFromFakeMethodWithComplexObject=[ -{FakeObject.fakeMethodWithComplexFakeObject=[{arg0=FakeObject(id=idMock, value=null, name=null, fakeObject=null)}]} -] \ No newline at end of file diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java deleted file mode 100644 index c6bd638..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package au.com.origin.snapshots.reporters; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.serializers.SerializerType; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; -import org.opentest4j.AssertionFailedError; - -class PlainTextSnapshotReporterTest { - private static final PlainTextSnapshotReporter REPORTER = new PlainTextSnapshotReporter(); - - @Test - void shouldSupportAllFormats() { - Assertions.assertThat(REPORTER.supportsFormat(SerializerType.TEXT.name())).isTrue(); - Assertions.assertThat(REPORTER.supportsFormat(SerializerType.JSON.name())).isTrue(); - - Assertions.assertThat(REPORTER.supportsFormat("xml")).isTrue(); - Assertions.assertThat(REPORTER.supportsFormat("blah")).isTrue(); - } - - @Test - void doReport() { - Snapshot snap1 = Snapshot.builder().name("snap1").scenario("A").body("[\nfoo\n]").build(); - Snapshot snap2 = Snapshot.builder().name("snap1").scenario("A").body("[\nbar\n]").build(); - assertThatExceptionOfType(AssertionFailedError.class) - .isThrownBy(() -> REPORTER.report(snap1, snap2)) - .withMessageContaining("expecting:") - .withMessageContaining("[\"foo\"]") - .withMessageContaining("but was:") - .withMessageContaining("[\"bar\"]"); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java deleted file mode 100644 index 7acd308..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package au.com.origin.snapshots.serializers; - -import static org.assertj.core.api.Assertions.assertThat; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotHeader; -import au.com.origin.snapshots.SnapshotSerializerContext; -import java.io.File; -import java.nio.file.Files; -import org.junit.jupiter.api.Test; - -public class Base64SnapshotSerializerTest { - - private SnapshotSerializerContext mockSnapshotGenerator = - new SnapshotSerializerContext( - "base64Test", - null, - new SnapshotHeader(), - Base64SnapshotSerializerTest.class, - null // it's not used in these scenarios - ); - - @Test - void shouldSnapshotAByteArray() { - Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); - Snapshot result = serializer.apply("John Doe".getBytes(), mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\nSm9obiBEb2U=\n]"); - } - - @Test - void shouldSnapshotAnyString() { - Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); - Snapshot result = serializer.apply("John Doe", mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\nSm9obiBEb2U=\n]"); - } - - @Test - void shouldSnapshotAFile() throws Exception { - Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); - File f = new File("src/test/resources/origin-logo.png"); - byte[] content = Files.readAllBytes(f.toPath()); - - Snapshot result = serializer.apply(content, mockSnapshotGenerator); - assertThat(result.getBody()) - .isEqualTo( - "[\niVBORw0KGgoAAAANSUhEUgAAAFgAAABYCAIAAAD+96djAAAKaklEQVR4nOxce3BcVRk/59zX3t3N5p3m1UeaNLQ2adKaFhDp9MFD3j7Qoqhg1VHpjEMR7CgKyghVQKa24wzSUhQcxwGLU0TsH0AphQLSxKSQJm02aRrSvDbPfd/HOddZ2LLJZp/n3F0aJr/Zf7J77nd+95fvfN85537n8oZhgHkAgD5pAhcK5oUIY16IMOaFCGNeiDD4rPVEpiZ1p1PvceLhITIyQlwuw+c1FMVQFGAYUJKAJEFZ5oqKUUkJKlnAL63mq5dxxcXZoQczmj7xqEtrflc7fUprbSGuEQoLMC9fbFzN1y4X1zRx5RUZ4Hi+o0wIQdxu5Y0jyuuv6p0dwDz73JIqacMmaf0mrrDILJsfw2Qh9L7ewMF/KEdfA5pmotkZQEhcd6l801eE5StNtGqaEHrfWf8z+9T/vWuiCyQGv2Kl7datwoo6U6yZI4Ty9lH/M0/i4UEzKKUB5Mi1bvm2ZfMXAM8a9VmFwMODvn171LZmRh4s4BYusf/gTqF2BYsRBiEwDhw66H/2L6H890kDIiRddb3tlq3QYqG0QCcEcU96//iw9l4LXa8ZAle5KOeu+7lSmixLI4Tu7PTseZCMuij6yzSg1WbftkNsXJf2hekKob7X7Nn1AFA/+eEQF4iz3bbNsunatC5KTwjl7SPevY8CPWNzBPMg33y79YZbUm+fRtZR3n7N+6ffhaYJkIpadhE48GcIoXz9lhTbpyqE2vqW78lHAJwbKnwE//NPAQ7J13w1lcYpCaF1d3gf3wkMAtHckeFDBA7sR3kF0qWbk7ZMLgSZHPM98RAg2hzdu/D9dTcqKhGW1SduliRY4vER3/5H9K73zaaXXUhS3kNPI7sjQZOEQhDi3nOv3tmaEXLZBbdoWe5dDwMp7rwzkbsHj76on24NNZn7H9zf5Xt+b4KbjSsEHh8JHHwqlCM+LR/l2EvaqbjeHTdYBl96xtAVYHaagILIV63ga1bxC2tQSQVy5ENeABACTSN+Dx45hwfO6N3va10njIDP3K5DSeTgPuHuPwDExSAWM0boHzg9j90JDGIiCW5hjXTZdWLDZVC2J2+tKWr7u8obL+rOEyZyAABYv7FdWnfl7O9jC+F54j6987hZfaOSSutN3xdWrKW4VjvTHvjXftzbCYA5G1+oYEHuz/YCLnooxBBC73d6dv3YlH6hbJO/vE1adRngBXorhGi9J/1/f4yMDZnACQDrLdultdFOESNYKq89F4ouzIGaW1ids323tGYDkwof7tYKS+sc23cLK9eZkkGCh58DBCcRgkyNqu3H2DsTVl7suONRrrCMSYJpgLLdfvsvpctvZOdGxvq17ujQEy2E2vwyMDBjouJr19i/dS8QJbNUOE+Ws974Q8umLeypVG15Jcp2dMzQuo4zrqygLdf6xTtmRyOzIG/cop8+jgd7WIzoPW0AY8BF8ugMj8DjQ7ivg0lsBK03b+cKy1lYJoFosd76c2i1sfA0vOPa2RkLqBlC6M5mxuEnXnKdcBFNmkwLXEGZfMOPGKnqXc1xhdC6W1hMw/xi65W3ZVqFjyA2bOSrG1jYat3xhCAE97ax+Ju86ZtAsmZHiFCwuHpraAVAy5a4eolvMoYQeKzf0ALUAqPCMrF+Q9ZUCA2QshrhIoaZBQR4sCuWEENOpujQeEXmMkU8iE3XsnDGg86PTUWo4+EelsQp1K1nvq/0O61qRPY8wz9FdzkeieTgiEcQ9zD1eENFFVx+JlNmPHA8t6SePky4R2IIYXhc1D7GLTKnSIEC/KJ6atqGJyJEZGgQ7yig3afmihebcE/UXdPSNhQP0BQgSDOEMDQfoA0RqCCDZV5Jus4vp6Yd+vcrPjRDCIIB0amlhdZEO+UZBbLmfrifSLt9ooefZp8XQldhSAVKbaGYvXlUNBAHJSnk4VQwooWAiNodQiA6w8XMgICe/PmN3PNCCFLIwWjLiAzVT0vEDBCVOkxAPrxpMm0uKEpAC9KZM7wuAJhquagRSnYsz+iFWUJAW67hphSCTJ2jJcIKMtHPMi6QFH62EBEC5ZRg7zCdQezqouXCCjzcQS0EyimaFSMAQI5iTLtdjodPAqxnf9EVSneDJ+gDRE6k9H+aEHmV9Isu3a8NtAoLmygvpwXxjxNXBzVtlBdZH0W8iiuuYVnS6l3R+8JZgOY8DAChXyIVVn1sappH5FayzFX1wVag+oBoY725dID73mLhjByRxy4Rj0D2YmgroHcK3ad0/pv1ztKBPtiGx04zeDFEhdUxhAiNjvJGltGhnXyeBCayJAPWlOP7WNiioqVIzostBF/ewPSwQPerLfuzo4PSfoBMnWVhy1fOCO0zEh5XtjqUAo3oB6SpQzv7OregTqi5muEekwO7Tqonn2UsYuErL57x5/Q/kJzHVzbhc++wdKC07IX2BXxpI4uRBCA+V/DYoxBgllUidCzkCmumfxNtTKi+isXfQh9DCx7bicczMtc0/KOBI/cZwTFGkkLVxijL0ULwpathTglLEAp9cDBw5Bf6cJu5KhDPgP/wDsM3wEqPF/glyYQAiBOqr2HtCQFAgsE3f612PDu7JIMOev+b/sN3G8FRdm784vVILoiyH6uGSvV6D30XYMqVaBS4guVC7Zf4skuoLeAJp+Z8Qe8/YgofAKC8eTfnWBT9bcxiMqX9aa3rgEkdh8CVNIq1X+OK0jupid29Wtc/9f6jLIksCnzF5y1r75n9fZwSZC3gP7zNCI6b1X24M8divmI9v6AJORJt/xPvOTzSrA8cI+OnzCqmCwPx8sY9yBajoCluLbb2watq224zSUyHlMc5qqC9AooOiMTQZAxrhuo2vOeI+4yhZGp6yi+9UfrM1pg/JSpKD/73V3j001CR/hGgvMB6+S7AyzF/TTQpEevuAILMOq24QD4ISvXb4qmQ/LyG1v+y2vEEIGo60l+IEJd/T1h8fYIGSTbXhMorIOKV9l0m84I8tBRBIQciCXASgBBgxcAK0H0kOAqIyWcpuaK1iVVI6SgTX74Buzv1/kMsVKBcyuXWopwa5KhG1jIo5SUYlYY6RQJDxNND3N3E7SS+syxvIODyV1oafpqcYUrnPokWbPsNmUizUF7M5Ys/h/JXoZylSC5J79ppMFQ38fTgiTY88qYRTO/4MbRWyGseBGJu8papHoDVA4HWew3vmRQ657jCJr50M1ewGiBz97UJnmjXB1/Bo2+lEragVCyt2YmkwlRMp3MSWJ0MnLjf8PXFbcDLfOkVfPm1SC5N1SYVDHVSGzikD/4HqO54baBUIK16AFlTrVdI70i0obmDrTuMYIznHyi3Tlr+EyjmpW6NFbpfcT6OXUdj/MRZLA2/RbY0ylfSf1sADgbadhj+iF9AqUhafg/KqU3PjkkggSH11O+J1zmNT6Glfie0pPfeJqr3R2hu5fRjeKotNBqKN4pV3wF8TtpGTATRtL6/aYMvAIMg+zLponuglPbbq6jfKEK0/gPItpTL/yzV5eYDe06RiXeEyq8DRHNOJrMv5JpDmJvnvTOAeSHCmBcijHkhwpgXIox5IcKYFyKM/wcAAP//h4bYYlJz5AYAAAAASUVORK5CYII=\n]"); - } - - @Test - void shouldSupportBase64SerializerType() { - Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); - assertThat(serializer.getOutputFormat()).isEqualTo("BASE64"); - } -} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java b/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java deleted file mode 100644 index b8035db..0000000 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package au.com.origin.snapshots.serializers; - -import static org.assertj.core.api.Assertions.assertThat; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotHeader; -import au.com.origin.snapshots.SnapshotSerializerContext; -import lombok.AllArgsConstructor; -import lombok.Data; -import org.junit.jupiter.api.Test; - -public class ToStringSnapshotSerializerTest { - ToStringSnapshotSerializer serializer = new ToStringSnapshotSerializer(); - - private SnapshotSerializerContext mockSnapshotGenerator = - new SnapshotSerializerContext( - "base64Test", - null, - new SnapshotHeader(), - ToStringSnapshotSerializerTest.class, - null // it's not used in these scenarios - ); - - @Test - void shouldSnapshotAnyString() { - Snapshot result = serializer.apply("John Doe", mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\nJohn Doe\n]"); - } - - @Test - void shouldSnapshotUnicode() { - Snapshot result = serializer.apply("🤔", mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\n🤔\n]"); - } - - @Test - void shouldSnapshotAnyObject() { - Snapshot result = serializer.apply(new Dummy(1, "John Doe"), mockSnapshotGenerator); - assertThat(result.getBody()) - .isEqualTo("[\nToStringSerializerTest.Dummy(id=1, name=John Doe)\n]"); - } - - @Test - void shouldSnapshotMultipleObjects() { - Snapshot result = serializer.apply(new Dummy(1, "John Doe"), mockSnapshotGenerator); - assertThat(result.getBody()) - .isEqualTo("[\nToStringSerializerTest.Dummy(id=1, name=John Doe)\n]"); - } - - @Test - void shouldSupportBase64SerializerType() { - assertThat(serializer.getOutputFormat()).isEqualTo("TEXT"); - } - - @Test - void shouldReplaceThreeConsecutiveNewLines() { - Snapshot result = serializer.apply("John\n\n\nDoe", mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\nJohn\n.\n.\nDoe\n]"); - } - - @Test - void shouldReplaceTwoConsecutiveNewLinesAtEnd() { - Snapshot result = serializer.apply("John Doe\n\n", mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\nJohn Doe\n.\n.\n]"); - } - - @Test - void shouldReplaceTwoConsecutiveNewLinesAtBeginning() { - Snapshot result = serializer.apply("\n\nJohn Doe", mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\n.\n.\nJohn Doe\n]"); - } - - @Test - void shouldReplaceIllegalNewlineSequencesEverywhere() { - Snapshot result = serializer.apply("\n\nJohn\n\n\nDoe\n\n", mockSnapshotGenerator); - assertThat(result.getBody()).isEqualTo("[\n.\n.\nJohn\n.\n.\nDoe\n.\n.\n]"); - } - - @AllArgsConstructor - @Data - private static class Dummy { - private int id; - private String name; - - public String toString() { - return "ToStringSerializerTest.Dummy(id=" + this.getId() + ", name=" + this.getName() + ")"; - } - } -} diff --git a/java-snapshot-testing-junit4/build.gradle b/java-snapshot-testing-junit4/build.gradle deleted file mode 100644 index 1545eb2..0000000 --- a/java-snapshot-testing-junit4/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -apply from: "../gradle/publishing.gradle" -apply from: "../gradle/spotless.gradle" - -dependencies { - implementation project(':java-snapshot-testing-core') - - // User supplied JUnit4 Version - compileOnly 'org.junit.platform:junit-platform-runner:1.2.0' - compileOnly 'org.junit.vintage:junit-vintage-engine:5.2.0' - - // Testing - testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' - testImplementation 'org.junit.platform:junit-platform-runner:1.2.0' - testImplementation 'org.junit.vintage:junit-vintage-engine:5.2.0' - testImplementation 'org.assertj:assertj-core:3.11.1' - - // Required java-snapshot-testing peer dependencies - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' -} - -publishing { - publications { - myPublication(MavenPublication) { - artifact shadowJar - groupId 'io.github.origin-energy' - artifactId 'java-snapshot-testing-junit4' - } - } -} \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SharedSnapshotHelpers.java b/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SharedSnapshotHelpers.java deleted file mode 100644 index c6b01e4..0000000 --- a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SharedSnapshotHelpers.java +++ /dev/null @@ -1,58 +0,0 @@ -package au.com.origin.snapshots.junit4; - -import au.com.origin.snapshots.*; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfigInjector; -import au.com.origin.snapshots.utils.ReflectionUtils; -import java.lang.reflect.Method; -import java.util.Arrays; -import org.junit.runner.Description; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; - -class SharedSnapshotHelpers implements SnapshotConfigInjector { - - public void injectExpectInstanceVariable( - SnapshotVerifier snapshotVerifier, Method testMethod, Object testInstance) { - - ReflectionUtils.findFieldByPredicate( - testInstance.getClass(), (field) -> field.getType() == Expect.class) - .ifPresent( - (field) -> { - Expect expect = Expect.of(snapshotVerifier, testMethod); - ReflectionUtils.makeAccessible(field); - try { - field.set(testInstance, expect); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); - } - - public Statement injectExpectMethodArgument( - SnapshotVerifier snapshotVerifier, FrameworkMethod method, Object test) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - method.invokeExplosively(test, new Expect(snapshotVerifier, method.getMethod())); - } - }; - } - - public boolean hasExpectArgument(FrameworkMethod method) { - return Arrays.asList(method.getMethod().getParameterTypes()).contains(Expect.class); - } - - @Override - public SnapshotConfig getSnapshotConfig() { - return new PropertyResolvingSnapshotConfig(); - } - - public SnapshotVerifier getSnapshotVerifier(Description description) { - // We don't want the orphan check to happen when the user runs a single test in their IDE - boolean failOnOrphans = description.getChildren().size() > 1; - - return new SnapshotVerifier(getSnapshotConfig(), description.getTestClass(), failOnOrphans); - } -} diff --git a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotClassRule.java b/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotClassRule.java deleted file mode 100644 index b04aef8..0000000 --- a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotClassRule.java +++ /dev/null @@ -1,29 +0,0 @@ -package au.com.origin.snapshots.junit4; - -import au.com.origin.snapshots.SnapshotVerifier; -import lombok.Getter; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -public class SnapshotClassRule implements TestRule { - - @Getter private SnapshotVerifier snapshotVerifier; - - @Getter private SharedSnapshotHelpers helpers = new SharedSnapshotHelpers(); - - @Override - public Statement apply(Statement base, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - snapshotVerifier = helpers.getSnapshotVerifier(description); - try { - base.evaluate(); - } finally { - snapshotVerifier.validateSnapshots(); - } - } - }; - } -} diff --git a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRule.java b/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRule.java deleted file mode 100644 index 88da396..0000000 --- a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRule.java +++ /dev/null @@ -1,32 +0,0 @@ -package au.com.origin.snapshots.junit4; - -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import lombok.RequiredArgsConstructor; -import org.junit.rules.MethodRule; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; - -@RequiredArgsConstructor -public class SnapshotRule implements MethodRule { - - private final SnapshotClassRule snapshotClassRule; - - @Override - public Statement apply(Statement base, FrameworkMethod method, Object test) { - final SharedSnapshotHelpers helpers = snapshotClassRule.getHelpers(); - helpers.injectExpectInstanceVariable( - snapshotClassRule.getSnapshotVerifier(), method.getMethod(), test); - if (helpers.hasExpectArgument(method)) { - throw new SnapshotExtensionException( - "Sorry, we don't support 'Expect' as a method argument for @Rule or @ClassRule. " - + "Please use an instance variable or @RunWith(SnapshotRunner.class) instead."); - } - - return new Statement() { - @Override - public void evaluate() throws Throwable { - base.evaluate(); - } - }; - } -} diff --git a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRunner.java b/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRunner.java deleted file mode 100644 index dfc954e..0000000 --- a/java-snapshot-testing-junit4/src/main/java/au/com/origin/snapshots/junit4/SnapshotRunner.java +++ /dev/null @@ -1,73 +0,0 @@ -package au.com.origin.snapshots.junit4; - -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.logging.LoggingHelper; -import java.util.List; -import lombok.extern.slf4j.Slf4j; -import org.junit.Test; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.Statement; - -/** - * Runner to enable java-snapshot-testing - * - *

If you are already using @RunWith for something else such as @RunWith(Parameterized.class) use - * these Rules instead. - * - * @see SnapshotClassRule - * @see SnapshotRule - *

{@code
- * {@literal @}ClassRule
- * public static SnapshotClassRule snapshotClassRule = new SnapshotClassRule();
- *
- * {@literal @}Rule
- * public SnapshotRule snapshotRule = new SnapshotRule(snapshotClassRule);
- *
- * private Expect expect;
- * }
- * Loosely based on: - * https://stackoverflow.com/questions/27745691/how-to-combine-runwith-with-runwithparameterized-class - */ -@Slf4j -public class SnapshotRunner extends BlockJUnit4ClassRunner { - - SnapshotVerifier snapshotVerifier; - - private SharedSnapshotHelpers helpers = new SharedSnapshotHelpers(); - - public SnapshotRunner(Class klass) throws InitializationError { - super(klass); - } - - @Override - protected Statement methodInvoker(FrameworkMethod method, Object test) { - boolean isTest = method.getMethod().isAnnotationPresent(Test.class); - if (isTest) { - helpers.injectExpectInstanceVariable(snapshotVerifier, method.getMethod(), test); - boolean shouldInjectMethodArgument = helpers.hasExpectArgument(method); - if (shouldInjectMethodArgument) { - LoggingHelper.deprecatedV5( - log, - "Injecting 'Expect' via method a argument is no longer recommended. Consider using instance variable injection instead."); - return helpers.injectExpectMethodArgument(snapshotVerifier, method, test); - } - } - - return super.methodInvoker(method, test); - } - - @Override - public void run(RunNotifier notifier) { - snapshotVerifier = helpers.getSnapshotVerifier(getDescription()); - super.run(notifier); - snapshotVerifier.validateSnapshots(); - } - - @Override - protected void validateTestMethods(List errors) { - // Disable as it checks for zero arguments - } -} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/BaseClassTest.java b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/BaseClassTest.java deleted file mode 100644 index fbd78ad..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/BaseClassTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.junit4.SnapshotRunner; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; - -@RunWith(Enclosed.class) -public class BaseClassTest { - - static class TestBase { - Expect expect; - } - - @RunWith(SnapshotRunner.class) - public static class NestedClass extends TestBase { - - @Test - public void helloWorldTest() { - expect.toMatchSnapshot("Hello World"); - } - } -} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/MyTest.java b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/MyTest.java deleted file mode 100644 index 9ad8827..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/MyTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.junit4.SnapshotRunner; -import junit.framework.TestCase; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(SnapshotRunner.class) -public class MyTest { - - @Test - public void someTest(Expect expect) { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void aNormalTest() { - TestCase.assertTrue(true); - } -} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/ParameterizedTest.java b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/ParameterizedTest.java deleted file mode 100644 index 444cb18..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/ParameterizedTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.junit4.SnapshotClassRule; -import au.com.origin.snapshots.junit4.SnapshotRule; -import java.util.Arrays; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Parameterized.class) -public class ParameterizedTest { - - @ClassRule public static SnapshotClassRule snapshotClassRule = new SnapshotClassRule(); - @Rule public SnapshotRule snapshotRule = new SnapshotRule(snapshotClassRule); - @Rule public TestName testName = new TestName(); - - private Expect expect; - - @Parameters(name = "letter is {0}") - public static Iterable data() { - return Arrays.asList(new Object[][] {{"a"}, {"b"}, {"c"}}); - } - - private String input; - - public ParameterizedTest(String input) { - this.input = input; - } - - @Test - public void test() { - expect.scenario(input).toMatchSnapshot(input); - } -} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRuleUsedTest.java b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRuleUsedTest.java deleted file mode 100644 index f7ee367..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRuleUsedTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit4.SnapshotClassRule; -import au.com.origin.snapshots.junit4.SnapshotRule; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; - -public class SnapshotRuleUsedTest { - - @ClassRule public static SnapshotClassRule snapshotClassRule = new SnapshotClassRule(); - - @Rule public SnapshotRule snapshotRule = new SnapshotRule(snapshotClassRule); - - private Expect expect; - - @Test - public void shouldUseExtensionViaInstanceVariable() { - this.expect.toMatchSnapshot("Hello World"); - } - - @Test - public void shouldUseExtensionAgainViaInstanceVariable() { - this.expect.toMatchSnapshot("Hello World"); - } - - @SnapshotName("hello_world") - @Test - public void shouldUseExtensionWithSnapshotName() { - expect.toMatchSnapshot("Hello World"); - } -} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/MyTest.snap b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/MyTest.snap deleted file mode 100644 index 63c07f0..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/MyTest.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.MyTest.someTest=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/ParameterizedTest.snap b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/ParameterizedTest.snap deleted file mode 100644 index 0a2175b..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/ParameterizedTest.snap +++ /dev/null @@ -1,13 +0,0 @@ -au.com.origin.snapshots.ParameterizedTest.test[a]=[ -a -] - - -au.com.origin.snapshots.ParameterizedTest.test[b]=[ -b -] - - -au.com.origin.snapshots.ParameterizedTest.test[c]=[ -c -] \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotContextRuleUsedTest.snap b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotContextRuleUsedTest.snap deleted file mode 100644 index cb453d4..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotContextRuleUsedTest.snap +++ /dev/null @@ -1,31 +0,0 @@ -au.com.origin.snapshots.SnapshotRuleUsedTest.shouldUseExtension=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotRuleUsedTest.shouldUseExtensionAgain=[ -Hello World -Hello World Again -] - - -au.com.origin.snapshots.SnapshotRuleUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ -Hello World -Hello World Again -] - - -au.com.origin.snapshots.SnapshotRuleUsedTest.shouldUseExtensionViaInstanceVariable=[ -Hello World -] - - -hello_world=[ -Hello World -] - - -hello_world_again=[ -Hello World -Hello World Again -] \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRuleUsedTest.snap b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRuleUsedTest.snap deleted file mode 100644 index 0aeefe0..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRuleUsedTest.snap +++ /dev/null @@ -1,13 +0,0 @@ -au.com.origin.snapshots.SnapshotRuleUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotRuleUsedTest.shouldUseExtensionViaInstanceVariable=[ -Hello World -] - - -hello_world=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRunnerUsedTest.snap b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRunnerUsedTest.snap deleted file mode 100644 index 7c762ff..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotRunnerUsedTest.snap +++ /dev/null @@ -1,28 +0,0 @@ -au.com.origin.snapshots.SnapshotRunnerUsedTest.shouldUseExtension=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotRunnerUsedTest.shouldUseExtensionAgain=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotRunnerUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotRunnerUsedTest.shouldUseExtensionViaInstanceVariable=[ -Hello World -] - - -hello_world=[ -Hello World -] - - -hello_world_again=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4RulesExample.java b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4RulesExample.java deleted file mode 100644 index a2b94d7..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4RulesExample.java +++ /dev/null @@ -1,25 +0,0 @@ -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit4.SnapshotClassRule; -import au.com.origin.snapshots.junit4.SnapshotRule; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; - -public class JUnit4RulesExample { - - @ClassRule public static SnapshotClassRule snapshotClassRule = new SnapshotClassRule(); - - @Rule public SnapshotRule snapshotRule = new SnapshotRule(snapshotClassRule); - - private Expect expect; - - @SnapshotName("my first test") - @Test - public void myTest1() { - // Verify your snapshot - expect.toMatchSnapshot("Hello World"); - } -} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4Example.snap b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4Example.snap deleted file mode 100644 index c7300b4..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4Example.snap +++ /dev/null @@ -1,8 +0,0 @@ -my first test=[ -Hello World -] - - -my second test=[ -Hello World Again -] \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4RulesExample.snap b/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4RulesExample.snap deleted file mode 100644 index 9561cb6..0000000 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit4RulesExample.snap +++ /dev/null @@ -1,3 +0,0 @@ -my first test=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-junit5/build.gradle b/java-snapshot-testing-junit5/build.gradle deleted file mode 100644 index b9d3251..0000000 --- a/java-snapshot-testing-junit5/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -apply from: "../gradle/publishing.gradle" -apply from: "../gradle/spotless.gradle" - -ext { - junitVersion = '5.7.2' -} - -dependencies { - implementation project(':java-snapshot-testing-core') - - // User supplied Junit5 version - compileOnly "org.junit.jupiter:junit-jupiter-api:${project.junitVersion}" - compileOnly "org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}" - - // Testing - testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' - testImplementation "org.junit.jupiter:junit-jupiter-params:${project.junitVersion}" - testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junitVersion}" - testImplementation "org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}" - testImplementation 'org.assertj:assertj-core:3.11.1' - - // Required java-snapshot-testing peer dependencies - testImplementation project(':java-snapshot-testing-plugin-jackson') - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' -} - -test { useJUnitPlatform() } - -publishing { - publications { - myPublication(MavenPublication) { - artifact shadowJar - groupId 'io.github.origin-energy' - artifactId 'java-snapshot-testing-junit5' - } - } -} \ No newline at end of file diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap deleted file mode 100644 index b8d8953..0000000 --- a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTest$NestedClassWithoutSnapshot.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson/build.gradle b/java-snapshot-testing-plugin-jackson/build.gradle deleted file mode 100644 index 0069ba1..0000000 --- a/java-snapshot-testing-plugin-jackson/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -apply from: "../gradle/publishing.gradle" -apply from: "../gradle/spotless.gradle" - -dependencies { - compileOnly project(':java-snapshot-testing-core') - - // Client needs to supply their own versions - compileOnly 'com.fasterxml.jackson.core:jackson-core:2.20.1' - compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.20.1' - - // User supplied Junit5 version - compileOnly 'org.junit.jupiter:junit-jupiter-api:5.3.2' - compileOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2' - - // Testing - testImplementation project(':java-snapshot-testing-core') - testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.3.2' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' - testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.3.2' - testImplementation 'org.assertj:assertj-core:3.11.1' - testImplementation 'org.skyscreamer:jsonassert:1.5.0' // For docs/ reporter example - - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.20.1' - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1' -} - -test { useJUnitPlatform() } - -publishing { - publications { - myPublication(MavenPublication) { - artifact shadowJar - groupId 'io.github.origin-energy' - artifactId 'java-snapshot-testing-plugin-jackson' - } - } -} \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson3/build.gradle b/java-snapshot-testing-plugin-jackson3/build.gradle deleted file mode 100644 index 4ebe348..0000000 --- a/java-snapshot-testing-plugin-jackson3/build.gradle +++ /dev/null @@ -1,53 +0,0 @@ -apply from: "../gradle/publishing.gradle" -apply from: "../gradle/spotless.gradle" - -sourceCompatibility = '17' -targetCompatibility = '17' - -java { - toolchain { languageVersion = JavaLanguageVersion.of(17) } -} - -tasks.withType(JavaCompile).configureEach { - options.release = 17 -} - - -dependencies { - compileOnly project(':java-snapshot-testing-core') - - // Client needs to supply their own versions - compileOnly 'tools.jackson.core:jackson-core:3.0.3' - compileOnly 'tools.jackson.core:jackson-databind:3.0.3' - - // User supplied Junit5 version - compileOnly 'org.junit.jupiter:junit-jupiter-api:5.3.2' - compileOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2' - - // Testing - testImplementation project(':java-snapshot-testing-core') - testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' - testImplementation 'org.junit.jupiter:junit-jupiter-params:5.3.2' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' - testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.3.2' - testImplementation 'org.assertj:assertj-core:3.11.1' - testImplementation 'org.skyscreamer:jsonassert:1.5.0' // For docs/ reporter example - - testImplementation 'tools.jackson.core:jackson-core:3.0.3' - testImplementation 'tools.jackson.core:jackson-databind:3.0.3' - - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2' - testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.3.2' -} - -test { useJUnitPlatform() } - -publishing { - publications { - myPublication(MavenPublication) { - artifact shadowJar - groupId 'io.github.origin-energy' - artifactId 'java-snapshot-testing-plugin-jackson' - } - } -} \ No newline at end of file diff --git a/java-snapshot-testing-spock/build.gradle b/java-snapshot-testing-spock/build.gradle deleted file mode 100644 index 3f59637..0000000 --- a/java-snapshot-testing-spock/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -plugins { - id 'groovy' -} - -apply from: "../gradle/publishing.gradle" -apply from: "../gradle/spotless-groovy.gradle" - -dependencies { - implementation project(':java-snapshot-testing-core') - - // User supplied Spock Version - compileOnly "org.codehaus.groovy:groovy:3.0.21" - compileOnly "org.spockframework:spock-core:2.3-groovy-3.0" - - // Testing - testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha0' - testImplementation "org.codehaus.groovy:groovy:3.0.21" - testImplementation "org.spockframework:spock-core:2.3-groovy-3.0" - testImplementation 'org.assertj:assertj-core:3.11.1' - - // Required java-snapshot-testing peer dependencies - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' -} - -tasks.withType(Test).configureEach { - useJUnitPlatform() -} - -publishing { - publications { - myPublication(MavenPublication) { - artifact shadowJar - groupId 'io.github.origin-energy' - artifactId 'java-snapshot-testing-spock' - } - } -} \ No newline at end of file diff --git a/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/EnableSnapshots.groovy b/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/EnableSnapshots.groovy deleted file mode 100644 index 9379c8c..0000000 --- a/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/EnableSnapshots.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package au.com.origin.snapshots.spock - -import org.spockframework.runtime.extension.ExtensionAnnotation - -import java.lang.annotation.ElementType -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy -import java.lang.annotation.Target - -@Retention(RetentionPolicy.RUNTIME) -@Target([ElementType.TYPE, ElementType.METHOD]) -@ExtensionAnnotation(SnapshotExtension) -@interface EnableSnapshots {} diff --git a/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotExtension.groovy b/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotExtension.groovy deleted file mode 100644 index 1ec0ae4..0000000 --- a/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotExtension.groovy +++ /dev/null @@ -1,28 +0,0 @@ -package au.com.origin.snapshots.spock - -import au.com.origin.snapshots.SnapshotVerifier -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig -import au.com.origin.snapshots.config.SnapshotConfig -import au.com.origin.snapshots.config.SnapshotConfigInjector -import org.spockframework.runtime.extension.AbstractAnnotationDrivenExtension -import org.spockframework.runtime.model.SpecInfo - -class SnapshotExtension extends AbstractAnnotationDrivenExtension implements SnapshotConfigInjector { - - SnapshotVerifier snapshotVerifier; - - void visitSpecAnnotation(EnableSnapshots annotation, SpecInfo spec) { - this.snapshotVerifier = new SnapshotVerifier(getSnapshotConfig(), spec.reflection, false) - } - - void visitSpec(SpecInfo spec) { - def snapshotMethodInterceptor = new SnapshotMethodInterceptor(snapshotVerifier) - spec.allFeatures.featureMethod*.addInterceptor(snapshotMethodInterceptor) - spec.addCleanupSpecInterceptor(snapshotMethodInterceptor) - } - - @Override - SnapshotConfig getSnapshotConfig() { - return new PropertyResolvingSnapshotConfig() - } -} \ No newline at end of file diff --git a/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotMethodInterceptor.groovy b/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotMethodInterceptor.groovy deleted file mode 100644 index ac94958..0000000 --- a/java-snapshot-testing-spock/src/main/groovy/au/com/origin/snapshots/spock/SnapshotMethodInterceptor.groovy +++ /dev/null @@ -1,58 +0,0 @@ -package au.com.origin.snapshots.spock - -import au.com.origin.snapshots.Expect -import au.com.origin.snapshots.utils.ReflectionUtils -import au.com.origin.snapshots.SnapshotVerifier -import au.com.origin.snapshots.logging.LoggingHelper -import org.slf4j.LoggerFactory -import org.spockframework.runtime.extension.AbstractMethodInterceptor -import org.spockframework.runtime.extension.IMethodInvocation - -import java.lang.reflect.Method - -// Based on this issue: https://github.com/spockframework/spock/issues/652 -class SnapshotMethodInterceptor extends AbstractMethodInterceptor { - private log = LoggerFactory.getLogger( SnapshotMethodInterceptor.class ) - private final SnapshotVerifier snapshotVerifier; - - SnapshotMethodInterceptor(SnapshotVerifier snapshotVerifier) { - this.snapshotVerifier = snapshotVerifier - } - - @Override - void interceptFeatureMethod(IMethodInvocation invocation) throws Throwable { - updateInstanceVariable(invocation.instance, invocation.feature.featureMethod.reflection) - - def parameterCount = invocation.method.reflection.parameterCount - if (parameterCount > invocation.arguments.length) { - def newArguments = new Object[parameterCount] - System.arraycopy invocation.arguments, 0, newArguments, 0, invocation.arguments.length - invocation.arguments = newArguments - } - invocation.method.reflection.parameterTypes.eachWithIndex { type, i -> - if (Expect.class == type) { - LoggingHelper.deprecatedV5(log, "Injecting 'Expect' via method a argument is no longer recommended. Consider using instance variable injection instead.") - invocation.arguments[i] = new Expect(snapshotVerifier, invocation.feature.featureMethod.reflection) - } - } - invocation.proceed() - } - - private void updateInstanceVariable(Object testInstance, Method testMethod) { - ReflectionUtils.findFieldByPredicate(testInstance.class, { field -> field.getType() == Expect.class }) - .ifPresent({ field -> - Expect expect = Expect.of(snapshotVerifier, testMethod); - ReflectionUtils.makeAccessible(field); - try { - field.set(testInstance, expect); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); - } - - @Override - void interceptCleanupSpecMethod(IMethodInvocation invocation) throws Throwable { - this.snapshotVerifier.validateSnapshots(); - } -} diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy deleted file mode 100644 index ed69922..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpecificationBase.groovy +++ /dev/null @@ -1,7 +0,0 @@ -package au.com.origin.snapshots - -import spock.lang.Specification - -class SpecificationBase extends Specification { - Expect expect -} \ No newline at end of file diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpockExtensionUsedSpec.groovy b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpockExtensionUsedSpec.groovy deleted file mode 100644 index e9bd9ea..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/SpockExtensionUsedSpec.groovy +++ /dev/null @@ -1,79 +0,0 @@ -package au.com.origin.snapshots - -import au.com.origin.snapshots.annotations.SnapshotName -import au.com.origin.snapshots.spock.EnableSnapshots -import spock.lang.Specification -import spock.lang.Unroll - -@EnableSnapshots -class SpockExtensionUsedSpec extends Specification { - - Expect expect - - @SnapshotName("Should use extension") - def "Should use extension"(Expect expect) { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } - - @SnapshotName("Should use extension again") - def "Should use extension again"(Expect expect) { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } - - @SnapshotName("Should use extension via instance variable") - def "Should use extension via instance variable"() { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } - - @SnapshotName("DataTable example 1") - @Unroll - def 'DataTable example 1: #letter'(def letter) { - given: 'I use an @Unroll function' - String result = letter.toUpperCase() - - when: 'I snapshot the letter' - expect.scenario("letter $letter").toMatchSnapshot(result) - - then: - true - - where: - [letter] << [['A'],['B'],['C']] - } - - - @SnapshotName("DataTable example 2") - def 'DataTable example 2: #scenario to uppercase'() { - when: 'I convert to uppercase' - String result = value.toUpperCase(); - then: 'Should convert letters to uppercase' - // Check you snapshot against your output using a unique scenario - expect.scenario(scenario).toMatchSnapshot(result) - where: - scenario | value - 'letter' | 'a' - 'number' | '1' - } - - @SnapshotName("Can run a non snapshot test") - def "Can run a non snapshot test"() { - when: - def isTrue = true - - then: - isTrue - } - -} diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/TestBaseSpec.groovy b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/TestBaseSpec.groovy deleted file mode 100644 index 9383a83..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/TestBaseSpec.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package au.com.origin.snapshots - -import au.com.origin.snapshots.annotations.SnapshotName -import au.com.origin.snapshots.spock.EnableSnapshots - -@EnableSnapshots -class TestBaseSpec extends SpecificationBase { - - @SnapshotName("Should use extension") - def "Should use extension"() { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } - -} diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/SpockExtensionUsedSpec.snap b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/SpockExtensionUsedSpec.snap deleted file mode 100644 index e29808b..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/SpockExtensionUsedSpec.snap +++ /dev/null @@ -1,38 +0,0 @@ -DataTable example 1[letter A]=[ -A -] - - -DataTable example 1[letter B]=[ -B -] - - -DataTable example 1[letter C]=[ -C -] - - -DataTable example 2[letter]=[ -A -] - - -DataTable example 2[number]=[ -1 -] - - -Should use extension again=[ -Hello World -] - - -Should use extension via instance variable=[ -Hello World -] - - -Should use extension=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/TestBaseSpec.snap b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/TestBaseSpec.snap deleted file mode 100644 index 7cf9614..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/__snapshots__/TestBaseSpec.snap +++ /dev/null @@ -1,3 +0,0 @@ -Should use extension=[ -Hello World -] \ No newline at end of file diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockExample.groovy b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockExample.groovy deleted file mode 100644 index 2eff02c..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockExample.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package au.com.origin.snapshots.docs - -import au.com.origin.snapshots.Expect -import au.com.origin.snapshots.annotations.SnapshotName -import au.com.origin.snapshots.spock.EnableSnapshots -import spock.lang.Specification - -// Ensure you enable snapshot testing support -@EnableSnapshots -class SpockExample extends Specification { - - // Option 1: inject Expect as an instance variable - private Expect expect - - // With spock tests you should always use @SnapshotName - otherwise they become coupled to test order - @SnapshotName("should_use_extension") - def "Should use extension"() { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } - - @SnapshotName("should_use_extension_as_method_argument") - // Option 2: inject Expect into the method signature - def "Should use extension as method argument"(Expect expect) { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } -} diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockWithParametersExample.groovy b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockWithParametersExample.groovy deleted file mode 100644 index 855bbcd..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/SpockWithParametersExample.groovy +++ /dev/null @@ -1,25 +0,0 @@ -package au.com.origin.snapshots.docs - -import au.com.origin.snapshots.Expect -import au.com.origin.snapshots.annotations.SnapshotName -import au.com.origin.snapshots.spock.EnableSnapshots -import spock.lang.Specification - -@EnableSnapshots -class SpockWithParametersExample extends Specification { - - private Expect expect - - @SnapshotName("convert_to_uppercase") - def 'Convert #scenario to uppercase'() { - when: 'I convert to uppercase' - String result = value.toUpperCase(); - then: 'Should convert letters to uppercase' - // Check you snapshot against your output using a unique scenario - expect.scenario(scenario).toMatchSnapshot(result) - where: - scenario | value - 'letter' | 'a' - 'number' | '1' - } -} \ No newline at end of file diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockExample.snap b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockExample.snap deleted file mode 100644 index 1a47743..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockExample.snap +++ /dev/null @@ -1,8 +0,0 @@ -should_use_extension=[ -Hello World -] - - -should_use_extension_as_method_argument=[ -Hello World -] diff --git a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockWithParametersExample.snap b/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockWithParametersExample.snap deleted file mode 100644 index 9cf3a21..0000000 --- a/java-snapshot-testing-spock/src/test/groovy/au/com/origin/snapshots/docs/__snapshots__/SpockWithParametersExample.snap +++ /dev/null @@ -1,8 +0,0 @@ -convert_to_uppercase[letter]=[ -A -] - - -convert_to_uppercase[number]=[ -1 -] \ No newline at end of file diff --git a/java-snapshot-testing-spock/src/test/resources/snapshot.properties b/java-snapshot-testing-spock/src/test/resources/snapshot.properties deleted file mode 100644 index 6c14caa..0000000 --- a/java-snapshot-testing-spock/src/test/resources/snapshot.properties +++ /dev/null @@ -1,7 +0,0 @@ -serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer -comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator -reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter -snapshot-dir=__snapshots__ -output-dir=src/test/groovy -ci-env-var=CI -update-snapshot=none \ No newline at end of file diff --git a/mvnw b/mvnw new file mode 100755 index 0000000..b7f0646 --- /dev/null +++ b/mvnw @@ -0,0 +1,287 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.1.1 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="`/usr/libexec/java_home`"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + printf '%s' "$(cd "$basedir"; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname $0)") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) wrapperUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $wrapperUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + QUIET="--quiet" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + QUIET="" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" + fi + [ $? -eq 0 ] || rm -f "$wrapperJarPath" + elif command -v curl > /dev/null; then + QUIET="--silent" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + QUIET="" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L + fi + [ $? -eq 0 ] || rm -f "$wrapperJarPath" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaSource="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=`cygpath --path --windows "$javaSource"` + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..474c9d6 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,187 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.1.1 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6f00cd7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,267 @@ + + + 4.0.0 + + + parent + io.github.finoid + 0.11.1 + + + io.github.finoid + snapshot-testing-parent + ${revision} + finoid-snapshot-testing-parent + A Java library designed to streamline testing by integrating Testcontainers, data fakers, test + fixtures, snapshot testing. + + pom + + + 21 + 21 + 21 + 21 + UTF-8 + + + 3.51.1 + + 1.7.3 + 1.0.0 + 1.18.42 + + + 0.10.0 + + + + false + + + + + + snapshot-testing-core + snapshot-testing-jackson + snapshot-testing-jackson3 + snapshot-testing-junit5 + snapshot-testing-junit6 + + + + + + + + + + + + + + + io.github.finoid + snapshot-testing-core + ${revision} + + + io.github.finoid + snapshot-testing-jackson + ${revision} + + + io.github.finoid + snapshot-testing-jackson3 + ${revision} + + + io.github.finoid + snapshot-testing-junit5 + ${revision} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.checkerframework + checker-qual + ${checker-qual.version} + + + + + + + + + + + + + + + + + + + + + + + + org.jspecify + jspecify + ${jspecify.version} + + + + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + + nicklaswallgren + Nicklas Wallgren + nicklas.wallgren@gmail.com + + + + + + The MIT License + https://opensource.org/licenses/MIT + repo + + + + + https://github.com/finoid/testify + scm:git:https://github.com/finoid/testify.git + scm:git:ssh://git@github.com/finoid/testify.git + HEAD + + + https://github.com/finoid/testify + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-versions + + enforce + + + true + + + true + + module-info + + org/jspecify/annotations/NullMarked + org/jspecify/annotations/NullUnmarked + org/jspecify/annotations/Nullable + org/jspecify/annotations/NonNull + org/jspecify/annotations/NonNull + + true + + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + ${flatten-maven-plugin.version} + + + oss + true + + + + flatten + process-resources + + flatten + + + + + flatten.clean + clean + + clean + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + ${maven.compiler.release} + + + + -parameters + + + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 8c2ac17..0000000 --- a/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = 'java-snapshot-testing' - -include 'java-snapshot-testing-core', 'java-snapshot-testing-junit4', 'java-snapshot-testing-junit5', 'java-snapshot-testing-spock', 'java-snapshot-testing-plugin-jackson', 'java-snapshot-testing-plugin-jackson3' \ No newline at end of file diff --git a/java-snapshot-testing-core/.gitignore b/snapshot-testing-core/.gitignore similarity index 100% rename from java-snapshot-testing-core/.gitignore rename to snapshot-testing-core/.gitignore diff --git a/snapshot-testing-core/pom.xml b/snapshot-testing-core/pom.xml new file mode 100644 index 0000000..421efac --- /dev/null +++ b/snapshot-testing-core/pom.xml @@ -0,0 +1,115 @@ + + + 4.0.0 + + io.github.finoid + snapshot-testing-parent + ${revision} + ../pom.xml + + + snapshot-testing-core + finoid-snapshot-testing-core + Core library for snapshot-testing + + + 21 + 21 + 21 + 21 + UTF-8 + + + + + org.checkerframework + checker-qual + + + + + com.fasterxml.jackson.core + jackson-core + 2.20.1 + provided + + + + com.fasterxml.jackson.core + jackson-databind + 2.20.1 + provided + + + + org.slf4j + slf4j-api + 2.0.17 + + + + org.slf4j + slf4j-simple + 2.0.17 + test + + + + + org.assertj + assertj-core + 3.11.1 + + + + org.opentest4j + opentest4j + 1.2.0 + + + + + org.mockito + mockito-junit-jupiter + 2.23.0 + test + + + + org.mockito + mockito-core + 2.23.4 + test + + + + org.junit.jupiter + junit-jupiter-api + 5.3.2 + test + + + + org.junit.jupiter + junit-jupiter-engine + 5.3.2 + test + + + + org.junit.jupiter + junit-jupiter-params + 5.3.2 + test + + + + commons-io + commons-io + 2.6 + test + + + \ No newline at end of file diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java new file mode 100644 index 0000000..b0d6ab9 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java @@ -0,0 +1,173 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.comparators.SnapshotComparator; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RequiredArgsConstructor +public class Expect { + private final SnapshotVerifier snapshotVerifier; + private final Method testMethod; + + private SnapshotSerializer snapshotSerializer; + private SnapshotComparator snapshotComparator; + private List snapshotReporters; + private String scenario; + + private final Map headers = new HashMap<>(); + + public static Expect of(SnapshotVerifier snapshotVerifier, Method method) { + return new Expect(snapshotVerifier, method); + } + + /** + * Make an assertion on the given input parameters against what already exists + * + *

If you were previously using varargs and see an error - you can fix the error using + * "toMatchSnapshotLegacy", however, a better approach is to use the ".scenario()" feature as + * future versions of this library will most likely remove the legacy implementation completely. + * + * @param object snapshot object + */ + public void toMatchSnapshot(Object object) { + SnapshotContext snapshotContext = snapshotVerifier.expectCondition(testMethod, object); + if (snapshotSerializer != null) { + snapshotContext.setSnapshotSerializer(snapshotSerializer); + } + if (snapshotComparator != null) { + snapshotContext.setSnapshotComparator(snapshotComparator); + } + if (snapshotReporters != null) { + snapshotContext.setSnapshotReporters(snapshotReporters); + } + if (scenario != null) { + snapshotContext.setScenario(scenario); + } + snapshotContext.header.putAll(headers); + + snapshotContext.checkValidContext(); + + snapshotContext.toMatchSnapshot(); + } + + /** + * Normally a snapshot can be applied only once to a test method. + * + *

For Parameterized tests where the same method is executed multiple times you can supply the + * scenario() to overcome this restriction. Ensure each scenario is unique. + * + * @param scenario - unique scenario description + * @return Snapshot + */ + public Expect scenario(String scenario) { + this.scenario = scenario; + return this; + } + + /** + * Apply a custom serializer for this snapshot + * + * @param serializer your custom serializer + * @return Snapshot + */ + public Expect serializer(SnapshotSerializer serializer) { + this.snapshotSerializer = serializer; + return this; + } + + /** + * Apply a custom serializer for this snapshot + * + * @param name - the {name} attribute serializer.{name} from snapshot.properties + * @return Snapshot + */ + public Expect serializer(String name) { + this.snapshotSerializer = SnapshotProperties.getInstance("serializer." + name); + return this; + } + + /** + * Apply a custom comparator for this snapshot + * + * @param comparator your custom comparator + * @return Snapshot + */ + public Expect comparator(SnapshotComparator comparator) { + this.snapshotComparator = comparator; + return this; + } + + /** + * Apply a custom comparator for this snapshot + * + * @param name the {name} attribute comparator.{name} from snapshot.properties + * @return Snapshot + */ + public Expect comparator(String name) { + this.snapshotComparator = SnapshotProperties.getInstance("comparator." + name); + return this; + } + + /** + * Apply a list of custom reporters for this snapshot This will replace the default reporters + * defined in the config + * + * @param reporters your custom reporters + * @return Snapshot + */ + public Expect reporters(SnapshotReporter... reporters) { + this.snapshotReporters = Arrays.asList(reporters); + return this; + } + + /** + * Apply a list of custom reporters for this snapshot This will replace the default reporters + * defined in the config + * + * @param name the {name} attribute reporters.{name} from snapshot.properties + * @return Snapshot + */ + public Expect reporters(String name) { + this.snapshotReporters = SnapshotProperties.getInstances("reporters." + name); + return this; + } + + /** + * Apply a custom serializer for this snapshot. + * + * @param serializer your custom serializer + * @return this + * @see au.com.origin.snapshots.serializers.SnapshotSerializer + *

Example implementations + * @see au.com.origin.snapshots.serializers.ToStringSnapshotSerializer + * @see au.com.origin.snapshots.serializers.Base64SnapshotSerializer + */ + @SneakyThrows + public Expect serializer(Class serializer) { + this.snapshotSerializer = serializer.getConstructor().newInstance(); + return this; + } + + /** + * Add anything you like to the snapshot header. + * + *

These custom headers can be used in serializers, comparators or reporters to change how they + * behave. + * + * @param key key + * @param value value + * @return Expect + */ + public Expect header(String key, String value) { + headers.put(key, value); + return this; + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java new file mode 100644 index 0000000..dccc4a0 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java @@ -0,0 +1,81 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.exceptions.LogGithubIssueException; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@EqualsAndHashCode +@Builder +@Getter +@RequiredArgsConstructor +public class Snapshot implements Comparable { + + private final String name; + private final String scenario; + private final SnapshotHeader header; + private final String body; + + @Override + public int compareTo(Snapshot other) { + return (name + scenario).compareTo(other.name + other.scenario); + } + + public String getIdentifier() { + return scenario == null ? name : String.format("%s[%s]", name, scenario); + } + + public static Snapshot parse(String rawText) { + String regex = + "^(?.*?)(\\[(?[^]]*)])?=(?

\\{[^}]*?})?(?(.*)$)"; + Pattern p = Pattern.compile(regex, Pattern.DOTALL); + Matcher m = p.matcher(rawText); + boolean found = m.find(); + if (!found) { + throw new LogGithubIssueException( + "Corrupt Snapshot (REGEX matches = 0): possibly due to manual editing or our REGEX failing\n" + + "Possible Solutions\n" + + "1. Ensure you have not accidentally manually edited the snapshot file!\n" + + "2. Compare the snapshot with GIT history"); + } + + String name = m.group("name"); + String scenario = m.group("scenario"); + String header = m.group("header"); + String snapshot = m.group("snapshot"); + + if (name == null || snapshot == null) { + throw new LogGithubIssueException( + "Corrupt Snapshot (REGEX name or snapshot group missing): possibly due to manual editing or our REGEX failing\n" + + "Possible Solutions\n" + + "1. Ensure you have not accidentally manually edited the snapshot file\n" + + "2. Compare the snapshot with your version control history"); + } + + return Snapshot.builder() + .name(name) + .scenario(scenario) + .header(SnapshotHeader.fromJson(header)) + .body(snapshot) + .build(); + } + + /** + * The raw string representation of the snapshot as it would appear in the *.snap file. + * + * @return raw snapshot + */ + public String raw() { + String headerJson = (header == null) || (header.size() == 0) ? "" : header.toJson(); + return getIdentifier() + "=" + headerJson + body; + } + + @Override + public String toString() { + return raw(); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java new file mode 100644 index 0000000..41540f2 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java @@ -0,0 +1,186 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.annotations.SnapshotName; +import au.com.origin.snapshots.comparators.SnapshotComparator; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.ReservedWordException; +import au.com.origin.snapshots.exceptions.SnapshotExtensionException; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Slf4j +public class SnapshotContext { + + private static final List RESERVED_WORDS = Arrays.asList("=", "[", "]"); + + private final SnapshotConfig snapshotConfig; + private final SnapshotFile snapshotFile; + + @Getter + final Class testClass; + + @Getter + final Method testMethod; + + final Object current; + private final boolean isCI; + + @Setter + private SnapshotSerializer snapshotSerializer; + @Setter + private SnapshotComparator snapshotComparator; + @Setter + private List snapshotReporters; + + @Setter + @Getter + String scenario; + + @Getter + SnapshotHeader header = new SnapshotHeader(); + + SnapshotContext( + SnapshotConfig snapshotConfig, + SnapshotFile snapshotFile, + Class testClass, + Method testMethod, + Object current) { + this.snapshotConfig = snapshotConfig; + this.snapshotFile = snapshotFile; + this.testClass = testClass; + this.testMethod = testMethod; + this.current = current; + + this.isCI = snapshotConfig.isCI(); + this.snapshotSerializer = snapshotConfig.getSerializer(); + this.snapshotComparator = snapshotConfig.getComparator(); + this.snapshotReporters = snapshotConfig.getReporters(); + this.scenario = null; + } + + public void toMatchSnapshot() { + + Set rawSnapshots = snapshotFile.getSnapshots(); + Snapshot previousSnapshot = getRawSnapshot(rawSnapshots); + Snapshot currentSnapshot = takeSnapshot(); + + if (previousSnapshot != null && shouldUpdateSnapshot()) { + snapshotFile.getSnapshots().remove(previousSnapshot); + previousSnapshot = null; + } + + if (previousSnapshot != null) { + snapshotFile.pushDebugSnapshot(currentSnapshot); + + // Match existing Snapshot + if (!snapshotComparator.matches(previousSnapshot, currentSnapshot)) { + snapshotFile.createDebugFile(currentSnapshot); + + List reporters = + snapshotReporters.stream() + .filter(reporter -> reporter.supportsFormat(snapshotSerializer.getOutputFormat())) + .collect(Collectors.toList()); + + if (reporters.isEmpty()) { + String comparator = snapshotComparator.getClass().getSimpleName(); + throw new IllegalStateException( + "No compatible reporters found for comparator " + comparator); + } + + List errors = new ArrayList<>(); + + for (SnapshotReporter reporter : reporters) { + try { + reporter.report(previousSnapshot, currentSnapshot); + } catch (Throwable t) { + errors.add(t); + } + } + + if (!errors.isEmpty()) { + throw new SnapshotMatchException("Error(s) matching snapshot(s)", errors); + } + } + } else { + if (this.isCI) { + log.error( + "We detected you are running on a CI Server - if this is incorrect please override the isCI() method in SnapshotConfig"); + throw new SnapshotMatchException( + "Snapshot [" + + resolveSnapshotIdentifier() + + "] not found. Has this snapshot been committed ?"); + } else { + log.warn( + "We detected you are running on a developer machine - if this is incorrect please override the isCI() method in SnapshotConfig"); + // Create New Snapshot + snapshotFile.pushSnapshot(currentSnapshot); + snapshotFile.pushDebugSnapshot(currentSnapshot); + } + } + } + + private boolean shouldUpdateSnapshot() { + if (snapshotConfig.updateSnapshot().isPresent() && snapshotConfig.isCI()) { + throw new SnapshotExtensionException( + "isCI=true & update-snapshot=" + + snapshotConfig.updateSnapshot() + + ". Updating snapshots on CI is not allowed"); + } + if (snapshotConfig.updateSnapshot().isPresent()) { + return resolveSnapshotIdentifier().contains(snapshotConfig.updateSnapshot().get()); + } else { + return false; + } + } + + private Snapshot getRawSnapshot(Collection rawSnapshots) { + synchronized (rawSnapshots) { + for (Snapshot rawSnapshot : rawSnapshots) { + if (rawSnapshot.getIdentifier().equals(resolveSnapshotIdentifier())) { + return rawSnapshot; + } + } + } + return null; + } + + private Snapshot takeSnapshot() { + SnapshotSerializerContext sg = SnapshotSerializerContext.from(this); + return snapshotSerializer.apply(current, sg); + } + + String resolveSnapshotIdentifier() { + String scenarioFormat = scenario == null ? "" : "[" + scenario + "]"; + return snapshotName() + scenarioFormat; + } + + private String snapshotName() { + SnapshotName snapshotName = testMethod.getAnnotation(SnapshotName.class); + return snapshotName == null + ? testClass.getName() + "." + testMethod.getName() + : snapshotName.value(); + } + + void checkValidContext() { + for (String rw : RESERVED_WORDS) { + if (snapshotName().contains(rw)) { + throw new ReservedWordException("snapshot name", rw, RESERVED_WORDS); + } + if (scenario != null && scenario.contains(rw)) { + throw new ReservedWordException("scenario name", rw, RESERVED_WORDS); + } + } + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java new file mode 100644 index 0000000..e0e1835 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java @@ -0,0 +1,171 @@ +package au.com.origin.snapshots; + +import lombok.Getter; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Slf4j +public class SnapshotFile { + + public static final String SPLIT_STRING = "\n\n\n"; + + private final String fileName; + private final Class testClass; + @Getter + private Set snapshots = Collections.synchronizedSortedSet(new TreeSet<>()); + private Set debugSnapshots = Collections.synchronizedSortedSet(new TreeSet<>()); + + public SnapshotFile(String srcDirPath, String fileName, Class testClass) throws IOException { + this.testClass = testClass; + this.fileName = srcDirPath + File.separator + fileName; + log.info("Snapshot File: " + this.fileName); + + StringBuilder fileContent = new StringBuilder(); + + try (BufferedReader br = + new BufferedReader( + new InputStreamReader(new FileInputStream(this.fileName), StandardCharsets.UTF_8))) { + + String sCurrentLine; + + while ((sCurrentLine = br.readLine()) != null) { + fileContent.append(sCurrentLine + "\n"); + } + + String fileText = fileContent.toString(); + if (!"".equals(fileText.trim())) { + snapshots = + Collections.synchronizedSortedSet( + Stream.of(fileContent.toString().split(SPLIT_STRING)) + .map(String::trim) + .map(Snapshot::parse) + .collect(Collectors.toCollection(TreeSet::new))); + } + } catch (IOException e) { + // ... + } + + deleteDebugFile(); + } + + private String getDebugFilename() { + return this.fileName + ".debug"; + } + + public File createDebugFile(Snapshot snapshot) { + File file = null; + try { + file = new File(getDebugFilename()); + file.getParentFile().mkdirs(); + file.createNewFile(); + + try (FileOutputStream fileStream = new FileOutputStream(file, false)) { + fileStream.write(snapshot.raw().getBytes(StandardCharsets.UTF_8)); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + return file; + } + + @SneakyThrows + public void deleteDebugFile() { + Files.deleteIfExists(Paths.get(getDebugFilename())); + } + + @SneakyThrows + public void delete() { + Files.deleteIfExists(Paths.get(this.fileName)); + } + + @SneakyThrows + public synchronized File createFileIfNotExists(String filename) { + Path path = Paths.get(filename); + if (!Files.exists(path)) { + Files.createDirectories(path.getParent()); + Files.createFile(path); + } + return path.toFile(); + } + + public void pushSnapshot(Snapshot snapshot) { + synchronized (snapshots) { + snapshots.add(snapshot); + TreeSet rawSnapshots = + snapshots.stream().map(Snapshot::raw).collect(Collectors.toCollection(TreeSet::new)); + updateFile(this.fileName, rawSnapshots); + } + } + + public synchronized void pushDebugSnapshot(Snapshot snapshot) { + debugSnapshots.add(snapshot); + TreeSet rawDebugSnapshots = + debugSnapshots.stream().map(Snapshot::raw).collect(Collectors.toCollection(TreeSet::new)); + updateFile(getDebugFilename(), rawDebugSnapshots); + } + + private void updateFile(String fileName, Set rawSnapshots) { + File file = createFileIfNotExists(fileName); + try (FileOutputStream fileStream = new FileOutputStream(file, false)) { + byte[] myBytes = String.join(SPLIT_STRING, rawSnapshots).getBytes(StandardCharsets.UTF_8); + fileStream.write(myBytes); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @SneakyThrows + public void cleanup() { + Path path = Paths.get(this.fileName); + if (Files.exists(path)) { + if (Files.size(path) == 0 || snapshotsAreTheSame()) { + deleteDebugFile(); + } + + if (Files.size(path) == 0) { + delete(); + } else { + String content = + new String(Files.readAllBytes(Paths.get(this.fileName)), StandardCharsets.UTF_8); + Files.write( + path, content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING); + } + } + } + + @SneakyThrows + private boolean snapshotsAreTheSame() { + Path path = Paths.get(this.getDebugFilename()); + if (Files.exists(path)) { + List snapshotFileContent = + Files.readAllLines(Paths.get(this.fileName), StandardCharsets.UTF_8); + List debugSnapshotFileContent = + Files.readAllLines(Paths.get(this.getDebugFilename()), StandardCharsets.UTF_8); + return Objects.equals(snapshotFileContent, debugSnapshotFileContent); + } + + return false; + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java new file mode 100644 index 0000000..fa2a290 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java @@ -0,0 +1,49 @@ +package au.com.origin.snapshots; + +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@RequiredArgsConstructor +public class SnapshotHeader extends HashMap { + + // + // Manual JSON serialization/deserialization as I don't want to + // include another dependency for it + // + @SneakyThrows + public String toJson() { + StringBuilder b = new StringBuilder(); + b.append("{\n"); + final int lastIndex = this.size(); + int currIndex = 0; + for (Map.Entry entry : this.entrySet()) { + currIndex++; + String format = currIndex == lastIndex ? " \"%s\": \"%s\"\n" : " \"%s\": \"%s\",\n"; + b.append(String.format(format, entry.getKey(), entry.getValue())); + } + b.append("}"); + return b.toString(); + } + + @SneakyThrows + public static SnapshotHeader fromJson(String json) { + SnapshotHeader snapshotHeader = new SnapshotHeader(); + + if (json == null) { + return snapshotHeader; + } + + String regex = "\\\"(?.*)\\\": \\\"(?.*)\\\""; + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(json); + while (m.find()) { + snapshotHeader.put(m.group("key"), m.group("value")); + } + return snapshotHeader; + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java new file mode 100644 index 0000000..d854792 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java @@ -0,0 +1,59 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.exceptions.MissingSnapshotPropertiesKeyException; +import lombok.extern.slf4j.Slf4j; + +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.stream.Collectors; + +@Slf4j +public enum SnapshotProperties { + INSTANCE; + + Properties snapshotProperties = new Properties(); + + SnapshotProperties() { + try { + InputStream in = + SnapshotProperties.class.getClassLoader().getResourceAsStream("snapshot.properties"); + snapshotProperties.load(in); + } catch (Exception e) { + // It's ok, if the SnapshotConfig implementation attempts to get a property they will receive + // a MissingSnapshotPropertiesKeyException + } + } + + public static String getOrThrow(String key) { + Object value = INSTANCE.snapshotProperties.get(key); + if (value == null) { + throw new MissingSnapshotPropertiesKeyException(key); + } + return value.toString(); + } + + public static T getInstance(String key) { + String value = SnapshotProperties.getOrThrow(key); + return createInstance(value); + } + + public static List getInstances(String key) { + String value = SnapshotProperties.getOrThrow(key); + return Arrays.stream(value.split(",")) + .map(String::trim) + .map(it -> (T) createInstance(it)) + .collect(Collectors.toList()); + } + + @SuppressWarnings("unchecked") + private static T createInstance(String className) { + try { + Class clazz = Class.forName(className); + return (T) clazz.newInstance(); + } catch (Exception e) { + throw new RuntimeException("Unable to instantiate class " + className, e); + } + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java new file mode 100644 index 0000000..39d41a1 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java @@ -0,0 +1,52 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.annotations.SnapshotName; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +import java.lang.reflect.Method; + +/** + * Contains details of the pending snapshot that can be modified in the Serializer prior to calling + * toSnapshot(). + */ +@AllArgsConstructor +public class SnapshotSerializerContext { + + @Getter + @Setter + private String name; + + @Getter + @Setter + private String scenario; + + @Getter + @Setter + private SnapshotHeader header; + + @Getter + private Class testClass; + + @Getter + private final Method testMethod; + + public static SnapshotSerializerContext from(SnapshotContext context) { + SnapshotName snapshotName = context.getTestMethod().getAnnotation(SnapshotName.class); + String name = + snapshotName == null + ? context.getTestClass().getName() + "." + context.getTestMethod().getName() + : snapshotName.value(); + return new SnapshotSerializerContext( + name, + context.getScenario(), + context.getHeader(), + context.getTestClass(), + context.getTestMethod()); + } + + public Snapshot toSnapshot(String body) { + return Snapshot.builder().name(name).scenario(scenario).header(header).body(body).build(); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java new file mode 100644 index 0000000..588e0ca --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java @@ -0,0 +1,153 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.annotations.SnapshotName; +import au.com.origin.snapshots.annotations.UseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotExtensionException; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +@Slf4j +@RequiredArgsConstructor +public class SnapshotVerifier { + + private final Class testClass; + private final SnapshotFile snapshotFile; + private final SnapshotConfig config; + private final boolean failOnOrphans; + + private final Collection calledSnapshots = + Collections.synchronizedCollection(new ArrayList<>()); + + public SnapshotVerifier(SnapshotConfig frameworkSnapshotConfig, Class testClass) { + this(frameworkSnapshotConfig, testClass, false); + } + + /** + * Instantiate before any tests have run for a given class + * + * @param frameworkSnapshotConfig configuration to use + * @param failOnOrphans should the test break if snapshots exist with no matching method in the + * test class + * @param testClass reference to class under test + */ + public SnapshotVerifier( + SnapshotConfig frameworkSnapshotConfig, Class testClass, boolean failOnOrphans) { + try { + verifyNoConflictingSnapshotNames(testClass); + + UseSnapshotConfig customConfig = testClass.getAnnotation(UseSnapshotConfig.class); + SnapshotConfig snapshotConfig = + customConfig == null ? frameworkSnapshotConfig : customConfig.value().newInstance(); + + // Matcher.quoteReplacement required for Windows + String testFilename = + testClass.getName().replaceAll("\\.", Matcher.quoteReplacement(File.separator)) + ".snap"; + + File fileUnderTest = new File(testFilename); + File snapshotDir = new File(fileUnderTest.getParentFile(), snapshotConfig.getSnapshotDir()); + + // Support legacy trailing space syntax + String testSrcDir = snapshotConfig.getOutputDir(); + String testSrcDirNoTrailing = + testSrcDir.endsWith("/") ? testSrcDir.substring(0, testSrcDir.length() - 1) : testSrcDir; + SnapshotFile snapshotFile = + new SnapshotFile( + testSrcDirNoTrailing, + snapshotDir.getPath() + File.separator + fileUnderTest.getName(), + testClass); + + this.testClass = testClass; + this.snapshotFile = snapshotFile; + this.config = snapshotConfig; + this.failOnOrphans = failOnOrphans; + + } catch (IOException | InstantiationException | IllegalAccessException e) { + throw new SnapshotExtensionException(e.getMessage()); + } + } + + private void verifyNoConflictingSnapshotNames(Class testClass) { + Map> allSnapshotAnnotationNames = + Arrays.stream(testClass.getDeclaredMethods()) + .filter(it -> it.isAnnotationPresent(SnapshotName.class)) + .map(it -> it.getAnnotation(SnapshotName.class)) + .map(SnapshotName::value) + .collect(Collectors.groupingBy(String::toString)); + + boolean hasDuplicateSnapshotNames = + allSnapshotAnnotationNames.entrySet().stream() + .filter(it -> it.getValue().size() > 1) + .peek( + it -> + log.error( + "Oops, looks like you set the same name of two separate snapshots @SnapshotName(\"{}\") in class {}", + it.getKey(), + testClass.getName())) + .count() + > 0; + if (hasDuplicateSnapshotNames) { + throw new SnapshotExtensionException("Duplicate @SnapshotName annotations found!"); + } + } + + @SneakyThrows + public SnapshotContext expectCondition(Method testMethod, Object object) { + SnapshotContext snapshotContext = + new SnapshotContext(config, snapshotFile, testClass, testMethod, object); + calledSnapshots.add(snapshotContext); + return snapshotContext; + } + + public void validateSnapshots() { + Set rawSnapshots = snapshotFile.getSnapshots(); + Set snapshotNames = + calledSnapshots.stream() + .map(SnapshotContext::resolveSnapshotIdentifier) + .collect(Collectors.toSet()); + List unusedSnapshots = new ArrayList<>(); + + for (Snapshot rawSnapshot : rawSnapshots) { + boolean foundSnapshot = false; + for (String snapshotName : snapshotNames) { + if (rawSnapshot.getIdentifier().equals(snapshotName)) { + foundSnapshot = true; + break; + } + } + if (!foundSnapshot) { + unusedSnapshots.add(rawSnapshot); + } + } + if (unusedSnapshots.size() > 0) { + List unusedRawSnapshots = + unusedSnapshots.stream().map(Snapshot::raw).collect(Collectors.toList()); + String errorMessage = + "All unused Snapshots:\n" + + String.join("\n", unusedRawSnapshots) + + "\n\nHave you deleted tests? Have you renamed a test method?"; + if (failOnOrphans) { + log.error(errorMessage); + throw new SnapshotMatchException("ERROR: Found orphan snapshots"); + } else { + log.warn(errorMessage); + } + } + snapshotFile.cleanup(); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java new file mode 100644 index 0000000..ff454c7 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java @@ -0,0 +1,16 @@ +package au.com.origin.snapshots.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Target({ElementType.METHOD}) +@Inherited +@Retention(RetentionPolicy.RUNTIME) +public @interface SnapshotName { + String value(); +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java new file mode 100644 index 0000000..e269e39 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java @@ -0,0 +1,18 @@ +package au.com.origin.snapshots.annotations; + +import au.com.origin.snapshots.config.SnapshotConfig; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Target({ElementType.TYPE}) +@Inherited +@Retention(RetentionPolicy.RUNTIME) +public @interface UseSnapshotConfig { + Class value(); +} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java similarity index 53% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java index c5f8925..d5d0e4f 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java @@ -8,10 +8,10 @@ public class PlainTextEqualsComparator extends au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator { - public PlainTextEqualsComparator() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator` in `snapshot.properties`"); - } + public PlainTextEqualsComparator() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator` in `snapshot.properties`"); + } } diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java similarity index 68% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java index 84a9899..934a07b 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java @@ -3,5 +3,5 @@ import au.com.origin.snapshots.Snapshot; public interface SnapshotComparator { - boolean matches(Snapshot previous, Snapshot current); + boolean matches(Snapshot previous, Snapshot current); } diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java similarity index 60% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java index e987613..c300909 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java @@ -5,8 +5,8 @@ public class PlainTextEqualsComparator implements SnapshotComparator { - @Override - public boolean matches(Snapshot previous, Snapshot current) { - return previous.getBody().equals(current.getBody()); - } + @Override + public boolean matches(Snapshot previous, Snapshot current) { + return previous.getBody().equals(current.getBody()); + } } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java new file mode 100644 index 0000000..05e8b6a --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java @@ -0,0 +1,78 @@ +package au.com.origin.snapshots.config; + +import au.com.origin.snapshots.SnapshotProperties; +import au.com.origin.snapshots.comparators.SnapshotComparator; +import au.com.origin.snapshots.exceptions.MissingSnapshotPropertiesKeyException; +import au.com.origin.snapshots.logging.LoggingHelper; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; +import java.util.Optional; + +@Slf4j +public class PropertyResolvingSnapshotConfig implements SnapshotConfig { + + @Override + public String getOutputDir() { + return SnapshotProperties.getOrThrow("output-dir"); + } + + @Override + public String getSnapshotDir() { + return SnapshotProperties.getOrThrow("snapshot-dir"); + } + + @Override + public Optional updateSnapshot() { + // This was the original way to update snapshots + Optional legacyFlag = + Optional.ofNullable(System.getProperty(JVM_UPDATE_SNAPSHOTS_PARAMETER)); + if (legacyFlag.isPresent()) { + LoggingHelper.deprecatedV5( + log, + "Passing -PupdateSnapshot will be removed in a future release. Consider using snapshot.properties 'update-snapshot' toggle instead"); + if ("false".equals(legacyFlag.get())) { + return Optional.empty(); + } + return legacyFlag; + } + + try { + String updateSnapshot = SnapshotProperties.getOrThrow("update-snapshot"); + if ("all".equals(updateSnapshot)) { + return Optional.of(""); + } else if ("none".equals(updateSnapshot)) { + return Optional.empty(); + } + return Optional.of(updateSnapshot); + } catch (MissingSnapshotPropertiesKeyException ex) { + LoggingHelper.deprecatedV5( + log, + "You do not have 'update-snapshot=none' defined in your snapshot.properties - consider adding it now"); + return Optional.empty(); + } + } + + @Override + public SnapshotSerializer getSerializer() { + return SnapshotProperties.getInstance("serializer"); + } + + @Override + public SnapshotComparator getComparator() { + return SnapshotProperties.getInstance("comparator"); + } + + @Override + public List getReporters() { + return SnapshotProperties.getInstances("reporters"); + } + + @Override + public boolean isCI() { + String envVariable = SnapshotProperties.getOrThrow("ci-env-var"); + return System.getenv(envVariable) != null; + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java new file mode 100644 index 0000000..309b9b2 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java @@ -0,0 +1,88 @@ +package au.com.origin.snapshots.config; + +import au.com.origin.snapshots.comparators.SnapshotComparator; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import au.com.origin.snapshots.serializers.SnapshotSerializer; + +import java.util.List; +import java.util.Optional; + +/** + * Snapshot Configuration ---------------------- + * + *

Implement this interface when integrating `java-snapshot-testing` with a custom testing + * library + */ +public interface SnapshotConfig { + @Deprecated + String JVM_UPDATE_SNAPSHOTS_PARAMETER = "updateSnapshot"; + + /** + * The base directory where files get written (excluding package directories) default: + * "src/test/java" + * + *

You might want to override if you have tests under "src/test/integration" for example + * + * @return snapshot output folder + */ + String getOutputDir(); + + /** + * Subdirectory to store snapshots in + * + * @return name of subdirectory + */ + String getSnapshotDir(); + + /** + * Optional + * + * @return snapshots should be updated automatically without verification + */ + default Optional updateSnapshot() { + return Optional.ofNullable(System.getProperty(JVM_UPDATE_SNAPSHOTS_PARAMETER)); + } + + /** + * Optional Override to supply your own custom serialization function + * + * @return custom serialization function + */ + SnapshotSerializer getSerializer(); + + /** + * Optional Override to supply your own custom comparator function + * + * @return custom comparator function + */ + SnapshotComparator getComparator(); + + /** + * Optional Override to supply your own custom reporter functions Reporters will run in the same + * sequence as provided. Reporters should throw exceptions to indicate comparison failure. + * Exceptions thrown from reporters are aggregated and reported together. Reporters that wish to + * leverage IDE comparison tools can use standard assertion libraries like assertj, junit jupiter + * assertions (or) opentest4j. + * + * @return custom reporter functions + */ + List getReporters(); + + /** + * Optional This method is meant to detect if we're running on a CI environment. This is used to + * determine the action to be taken when a snapshot is not found. + * + *

If this method returns false, meaning we're NOT running on a CI environment (probably a dev + * machine), a new snapshot is created when not found. + * + *

If this method returns true, meaning we're running on a CI environment, no new snapshots are + * created and an error is thrown instead to prevent tests from silently passing when snapshots + * are not found. + * + *

Often to determine if running on a CI environment is to check for the presence of a 'CI' env + * variable + * + * @return boolean indicating if we're running on a CI environment or not + */ + boolean isCI(); +} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java similarity index 68% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java index 46d4d01..0284aa8 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java @@ -1,5 +1,5 @@ package au.com.origin.snapshots.config; public interface SnapshotConfigInjector { - SnapshotConfig getSnapshotConfig(); + SnapshotConfig getSnapshotConfig(); } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java new file mode 100644 index 0000000..a19bfdf --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java @@ -0,0 +1,12 @@ +package au.com.origin.snapshots.exceptions; + +public class LogGithubIssueException extends RuntimeException { + + private static final String LOG_SUPPORT_TICKET = + "\n\n*** This exception should never be thrown ***\n" + + "Log a support ticket at https://github.com/origin-energy/java-snapshot-testing/issues with details of the exception\n"; + + public LogGithubIssueException(String message) { + super(message + LOG_SUPPORT_TICKET); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java new file mode 100644 index 0000000..2b8b9a6 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java @@ -0,0 +1,8 @@ +package au.com.origin.snapshots.exceptions; + +public class MissingSnapshotPropertiesKeyException extends RuntimeException { + + public MissingSnapshotPropertiesKeyException(String key) { + super("\"snapshot.properties\" is missing required key=" + key); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java new file mode 100644 index 0000000..6203059 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java @@ -0,0 +1,18 @@ +package au.com.origin.snapshots.exceptions; + +import java.util.List; +import java.util.stream.Collectors; + +public class ReservedWordException extends RuntimeException { + + public ReservedWordException(String message) { + super(message); + } + + public ReservedWordException(String element, String reservedWord, List reservedWords) { + super( + String.format( + "You cannot use the '%s' character inside '%s'. Reserved characters are ", + reservedWord, element, reservedWords.stream().collect(Collectors.joining(",")))); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java new file mode 100644 index 0000000..a78d8f6 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java @@ -0,0 +1,12 @@ +package au.com.origin.snapshots.exceptions; + +public class SnapshotExtensionException extends RuntimeException { + + public SnapshotExtensionException(String message) { + super(message); + } + + public SnapshotExtensionException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java new file mode 100644 index 0000000..78fcaab --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java @@ -0,0 +1,21 @@ +package au.com.origin.snapshots.exceptions; + +import org.opentest4j.MultipleFailuresError; + +import java.util.Collections; +import java.util.List; + +public class SnapshotMatchException extends MultipleFailuresError { + + public SnapshotMatchException(String message) { + super(message, Collections.emptyList()); + } + + public SnapshotMatchException(String message, Throwable cause) { + super(message, Collections.singletonList(cause)); + } + + public SnapshotMatchException(String message, List causes) { + super(message, causes); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java new file mode 100644 index 0000000..c7e927e --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java @@ -0,0 +1,13 @@ +package au.com.origin.snapshots.logging; + +import org.slf4j.Logger; + +public class LoggingHelper { + + public static void deprecatedV5(Logger log, String message) { + log.warn( + "\n\n** Deprecation Warning **\nThis feature will be removed in version 5.X\n" + + message + + "\n\n"); + } +} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java similarity index 53% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java index 9daf4f5..218b6c0 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java @@ -8,10 +8,10 @@ public class PlainTextSnapshotReporter extends au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter { - public PlainTextSnapshotReporter() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter` in `snapshot.properties`"); - } + public PlainTextSnapshotReporter() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter` in `snapshot.properties`"); + } } diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java similarity index 55% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java index 39fd9e9..ab6d2f6 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java @@ -4,7 +4,7 @@ public interface SnapshotReporter { - boolean supportsFormat(String outputFormat); + boolean supportsFormat(String outputFormat); - void report(Snapshot previous, Snapshot current); + void report(Snapshot previous, Snapshot current); } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java new file mode 100644 index 0000000..1a4c1c0 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java @@ -0,0 +1,41 @@ +package au.com.origin.snapshots.reporters.v1; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import org.assertj.core.util.diff.DiffUtils; +import org.assertj.core.util.diff.Patch; +import org.opentest4j.AssertionFailedError; + +import java.util.Arrays; +import java.util.function.Supplier; + +public class PlainTextSnapshotReporter implements SnapshotReporter { + + private static final Supplier NO_DIFF_EXCEPTION_SUPPLIER = + () -> + new IllegalStateException( + "No differences found. Potential mismatch between comparator and reporter"); + + public static String getDiffString(Patch patch) { + return patch.getDeltas().stream() + .map(delta -> delta.toString() + "\n") + .reduce(String::concat) + .orElseThrow(NO_DIFF_EXCEPTION_SUPPLIER); + } + + @Override + public boolean supportsFormat(String outputFormat) { + return true; // always true + } + + @Override + public void report(Snapshot previous, Snapshot current) { + Patch patch = + DiffUtils.diff( + Arrays.asList(previous.raw().split("\n")), Arrays.asList(current.raw().split("\n"))); + + String message = "Error on: \n" + current.raw() + "\n\n" + getDiffString(patch); + + throw new AssertionFailedError(message, previous.raw(), current.raw()); + } +} diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java similarity index 65% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java index 4a08d98..3551fb9 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java @@ -11,10 +11,10 @@ @Deprecated public class Base64SnapshotSerializer extends au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer { - public Base64SnapshotSerializer() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer` in `snapshot.properties`"); - } + public Base64SnapshotSerializer() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer` in `snapshot.properties`"); + } } diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java similarity index 70% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java index 62915f3..4f320c0 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java @@ -1,7 +1,7 @@ package au.com.origin.snapshots.serializers; public enum SerializerType { - TEXT, - JSON, - BASE64; + TEXT, + JSON, + BASE64; } diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java similarity index 90% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java index d774561..a0dca36 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java @@ -2,9 +2,10 @@ import au.com.origin.snapshots.Snapshot; import au.com.origin.snapshots.SnapshotSerializerContext; + import java.util.function.BiFunction; public interface SnapshotSerializer extends BiFunction { - String getOutputFormat(); + String getOutputFormat(); } diff --git a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java similarity index 63% rename from java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java rename to snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java index c4c1325..54ac1bc 100644 --- a/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java @@ -12,10 +12,10 @@ @Deprecated public class ToStringSnapshotSerializer extends au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer { - public ToStringSnapshotSerializer() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer` in `snapshot.properties`"); - } + public ToStringSnapshotSerializer() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer` in `snapshot.properties`"); + } } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java new file mode 100644 index 0000000..db63063 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java @@ -0,0 +1,36 @@ +package au.com.origin.snapshots.serializers.v1; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; + +/** + * This Serializer converts a byte[] into a base64 encoded string. If the input is not a byte[] it + * will be converted using `.getBytes(StandardCharsets.UTF_8)` method + */ +public class Base64SnapshotSerializer implements SnapshotSerializer { + private static final ToStringSnapshotSerializer toStringSnapshotSerializer = + new ToStringSnapshotSerializer(); + + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + if (object == null) { + toStringSnapshotSerializer.apply("", gen); + } + byte[] bytes = + object instanceof byte[] + ? (byte[]) object + : object.toString().getBytes(StandardCharsets.UTF_8); + String encoded = Base64.getEncoder().encodeToString(bytes); + return toStringSnapshotSerializer.apply(encoded, gen); + } + + @Override + public String getOutputFormat() { + return SerializerType.BASE64.name(); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java new file mode 100644 index 0000000..f43faf9 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java @@ -0,0 +1,33 @@ +package au.com.origin.snapshots.serializers.v1; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotFile; +import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import lombok.extern.slf4j.Slf4j; + +/** + * This Serializer does a snapshot of the {@link Object#toString()} method + * + *

Will render each toString() on a separate line + */ +@Slf4j +public class ToStringSnapshotSerializer implements SnapshotSerializer { + + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + String body = "[\n" + object.toString() + "\n]"; + if (body.contains(SnapshotFile.SPLIT_STRING)) { + log.warn( + "Found 3 consecutive lines in your snapshot \\n\\n\\n. This sequence is reserved as the snapshot separator - replacing with \\n.\\n.\\n"); + body = body.replaceAll(SnapshotFile.SPLIT_STRING, "\n.\n.\n"); + } + return gen.toSnapshot(body); + } + + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java new file mode 100644 index 0000000..91614a1 --- /dev/null +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java @@ -0,0 +1,49 @@ +package au.com.origin.snapshots.utils; + +import lombok.experimental.UtilityClass; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Optional; +import java.util.function.Predicate; + +@UtilityClass +public class ReflectionUtils { + + /** + * Find {@link Field} by given predicate. + * + *

Invoke the given predicate on all fields in the target class, going up the class hierarchy + * to get all declared fields. + * + * @param clazz the target class to analyze + * @param predicate the predicate + * @return the field or empty optional + */ + public static Optional findFieldByPredicate( + final Class clazz, final Predicate predicate) { + Class targetClass = clazz; + + do { + final Field[] fields = targetClass.getDeclaredFields(); + for (final Field field : fields) { + if (!predicate.test(field)) { + continue; + } + return Optional.of(field); + } + targetClass = targetClass.getSuperclass(); + } while (targetClass != null && targetClass != Object.class); + + return Optional.empty(); + } + + public static void makeAccessible(final Field field) { + if ((!Modifier.isPublic(field.getModifiers()) + || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) + || Modifier.isFinal(field.getModifiers())) + && !field.isAccessible()) { + field.setAccessible(true); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java new file mode 100644 index 0000000..27e33fb --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java @@ -0,0 +1,64 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class CustomFolderSnapshotTest { + + private static final String OUTPUT_FILE = + "src/test/some-folder/au/com/origin/snapshots/__snapshots__/CustomFolderSnapshotTest.snap"; + + @BeforeEach + public void beforeEach() throws IOException { + Path path = Paths.get(OUTPUT_FILE); + Files.deleteIfExists(path); + } + + @Test + void shouldBeAbleToChangeSnapshotFolder(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new CustomFolderSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(FakeObject.builder().id("shouldBeAbleToChangeSnapshotFolder").build()); + snapshotVerifier.validateSnapshots(); + + Path path = Paths.get(OUTPUT_FILE); + Assertions.assertThat(Files.exists(path)); + } + + @Test + void shouldBeAbleToChangeSnapshotFolderLegacyTrailginSlash(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new CustomFolderSnapshotConfigLegacy(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(FakeObject.builder().id("shouldBeAbleToChangeSnapshotFolder").build()); + snapshotVerifier.validateSnapshots(); + + Path path = Paths.get(OUTPUT_FILE); + Assertions.assertThat(Files.exists(path)); + } + + public static class CustomFolderSnapshotConfig extends BaseSnapshotConfig { + + @Override + public String getOutputDir() { + return "src/test/some-folder"; + } + } + + public static class CustomFolderSnapshotConfigLegacy extends BaseSnapshotConfig { + + @Override + public String getOutputDir() { + return "src/test/some-folder/"; + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java new file mode 100644 index 0000000..7741130 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java @@ -0,0 +1,97 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import lombok.SneakyThrows; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collection; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +class DebugSnapshotLineEndingsTest { + private static final SnapshotConfig CONFIG = + new BaseSnapshotConfig() { + @Override + public SnapshotSerializer getSerializer() { + return new MultiLineSnapshotSerializer(); + } + }; + private static final String DEBUG_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap.debug"; + private static final String SNAPSHOT_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap"; + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + } + + @SneakyThrows + @BeforeEach + void beforeEach() { + Files.deleteIfExists(Paths.get(DEBUG_FILE_PATH)); + } + + /** + * Scenario: - An existing snapshot file checked out from git will have CR LF line endings on + * Windows OS - A newly created snapshot file will have LF line endings on any OS (see + * MultiLineSnapshotSerializer) Expectation: - As snapshot file content is identical (except for + * line endings), the debug file should not be created + */ + @DisplayName( + "Debug file should not be created when snapshots match the existing snapshot regardless of line endings") + @Test + void existingSnapshotDifferentLineEndings(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); + + SnapshotVerifier snapshotVerifier = new SnapshotVerifier(CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(Arrays.asList("a", "b")); + snapshotVerifier.validateSnapshots(); + + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH)), "Debug file should not be created"); + } + + private static class MultiLineSnapshotSerializer implements SnapshotSerializer { + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } + + @Override + public Snapshot apply(Object object, SnapshotSerializerContext snapshotSerializerContext) { + Object body = + "[\n" + + Arrays.asList(object).stream() + .flatMap( + o -> { + if (o instanceof Collection) { + return ((Collection) o).stream(); + } + return Stream.of(o); + }) + .map(Object::toString) + .collect(Collectors.joining("\n")) + + "\n]"; + + return Snapshot.builder() + .name( + "au.com.origin.snapshots.DebugSnapshotLineEndingsTest.existingSnapshotDifferentLineEndings") + .body(body.toString()) + .build(); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java new file mode 100644 index 0000000..47735ba --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java @@ -0,0 +1,116 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +import lombok.SneakyThrows; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@ExtendWith(MockitoExtension.class) +public class DebugSnapshotTest { + + private static final SnapshotConfig DEFAULT_CONFIG = + new BaseSnapshotConfig() { + @Override + public SnapshotSerializer getSerializer() { + return new ToStringSnapshotSerializer(); + } + }; + + private static final String DEBUG_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotTest.snap.debug"; + private static final String SNAPSHOT_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotTest.snap"; + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + } + + @SneakyThrows + @BeforeEach + public void beforeEach() { + Files.deleteIfExists(Paths.get(DEBUG_FILE_PATH)); + } + + @DisplayName("Debug file should be created when snapshots don't match") + @Test + void createDebugFile(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); + assertThrows(SnapshotMatchException.class, () -> expect.toMatchSnapshot(new TestObjectBad())); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); + } + + @DisplayName("Debug file should be created when snapshots match for a new snapshot") + @Test + void debugFileCreatedNewSnapshot(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); + expect.toMatchSnapshot(new TestObjectGood()); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); + } + + @DisplayName("Debug file should be created when snapshots match for an existing snapshot") + @Test + void debugFileCreatedExistingSnapshot(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); + expect.toMatchSnapshot(new TestObjectGood()); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); + } + + @SneakyThrows + @DisplayName("Existing debug file should not be deleted once snapshots match") + @Test + void debugFileCreatedSnapshotMatch(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + Files.createFile(Paths.get(DEBUG_FILE_PATH)); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(new TestObjectGood()); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); + } + + private static class TestObjectBad { + @Override + public String toString() { + return "Bad Snapshot"; + } + } + + private static class TestObjectGood { + @Override + public String toString() { + return "Good Snapshot"; + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java new file mode 100644 index 0000000..4afb9ed --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java @@ -0,0 +1,63 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.ToStringSnapshotConfig; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class EmptySnapshotFileTest { + + private static final String SNAPSHOT_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest.snap"; + private static final String DEBUG_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug"; + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + } + + @DisplayName("Should remove empty snapshots") + @Test + public void shouldRemoveEmptySnapshots(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new ToStringSnapshotConfig(), testInfo.getTestClass().get()); + snapshotVerifier.validateSnapshots(); + + assertTrue(Files.notExists(Paths.get(SNAPSHOT_FILE_PATH))); + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); + } + + @Nested + public class NestedClass { + + private static final String SNAPSHOT_FILE_PATH_NESTED = + "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap"; + private static final String DEBUG_FILE_PATH_NESTED = + "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug"; + + @DisplayName("Should remove empty nested snapshots") + @Test + public void shouldRemoveEmptyNestedSnapshots(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH_NESTED))); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH_NESTED))); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new ToStringSnapshotConfig(), testInfo.getTestClass().get()); + snapshotVerifier.validateSnapshots(); + + assertTrue(Files.notExists(Paths.get(SNAPSHOT_FILE_PATH_NESTED))); + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH_NESTED))); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java new file mode 100644 index 0000000..2cf884f --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java @@ -0,0 +1,39 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.ToStringSnapshotConfig; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class EqualDebugSnapshotFileTest { + + private static final String SNAPSHOT_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap"; + private static final String DEBUG_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug"; + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + } + + @DisplayName("Should remove equal debug snapshots") + @Test + public void shouldRemoveEmptySnapshots(TestInfo testInfo) { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + assertTrue(Files.exists(Paths.get(DEBUG_FILE_PATH))); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new ToStringSnapshotConfig(), testInfo.getTestClass().get()); + snapshotVerifier.validateSnapshots(); + + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + assertTrue(Files.notExists(Paths.get(DEBUG_FILE_PATH))); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java new file mode 100644 index 0000000..a36a9e7 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java @@ -0,0 +1,34 @@ +package au.com.origin.snapshots; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +@ToString +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FakeObject { + + private String id; + + private Integer value; + + private String name; + + @Setter + private FakeObject fakeObject; + + public void fakeMethod(String fakeName, Long fakeNumber, List fakeList) { + } + + public void fakeMethodWithComplexObject(Object fakeObj) { + } + + public void fakeMethodWithComplexFakeObject(FakeObject fakeObj) { + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java new file mode 100644 index 0000000..15785a7 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java @@ -0,0 +1,40 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.comparators.PlainTextEqualsComparator; +import au.com.origin.snapshots.reporters.PlainTextSnapshotReporter; +import au.com.origin.snapshots.serializers.Base64SnapshotSerializer; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * These classes are likely defined in snapshot.properties as a string. + * + *

The clients IDE will not complain if they change so ensure they don't + */ +public class NoNameChangeTest { + + @Test + public void serializersApiShouldNotChange() { + assertThat(Base64SnapshotSerializer.class.getName()) + .isEqualTo("au.com.origin.snapshots.serializers.Base64SnapshotSerializer"); + assertThat(ToStringSnapshotSerializer.class.getName()) + .isEqualTo("au.com.origin.snapshots.serializers.ToStringSnapshotSerializer"); + assertThat(SerializerType.class.getName()) + .isEqualTo("au.com.origin.snapshots.serializers.SerializerType"); + } + + @Test + public void reportersApiShouldNotChange() { + assertThat(PlainTextSnapshotReporter.class.getName()) + .isEqualTo("au.com.origin.snapshots.reporters.PlainTextSnapshotReporter"); + } + + @Test + public void comparatorsApiShouldNotChange() { + assertThat(PlainTextEqualsComparator.class.getName()) + .isEqualTo("au.com.origin.snapshots.comparators.PlainTextEqualsComparator"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java new file mode 100644 index 0000000..5581c44 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java @@ -0,0 +1,72 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class OnLoadSnapshotFileTest { + + private static final String SNAPSHOT_FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/OnLoadSnapshotFileTest.snap"; + private final SnapshotConfig CUSTOM_SNAPSHOT_CONFIG = new BaseSnapshotConfig(); + + @BeforeAll + static void beforeAll() throws IOException { + Files.deleteIfExists(Paths.get(SNAPSHOT_FILE_PATH)); + String snapshotFileContent = + "au.com.origin.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" + + "any special characters that need correct encoding äöüèéàè\n" + + "]"; + createSnapshotFile(snapshotFileContent); + } + + private static void createSnapshotFile(String snapshot) { + try { + File file = new File(SNAPSHOT_FILE_PATH); + file.getParentFile().mkdirs(); + file.createNewFile(); + try (FileOutputStream fileStream = new FileOutputStream(file, false)) { + fileStream.write(snapshot.getBytes(StandardCharsets.UTF_8)); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + @DisplayName("Should load snapshots with correct encoding") + @Test + public void shouldLoadFileWithCorrectEncodingForCompare(TestInfo testInfo) throws IOException { + assertTrue(Files.exists(Paths.get(SNAPSHOT_FILE_PATH))); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(CUSTOM_SNAPSHOT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect + .serializer(ToStringSnapshotSerializer.class) + .toMatchSnapshot("any special characters that need correct encoding äöüèéàè"); + snapshotVerifier.validateSnapshots(); + + File f = new File(SNAPSHOT_FILE_PATH); + assertThat(String.join("\n", Files.readAllLines(f.toPath()))) + .isEqualTo( + "au.com.origin.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" + + "any special characters that need correct encoding äöüèéàè\n" + + "]"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java new file mode 100644 index 0000000..16e6bb9 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java @@ -0,0 +1,76 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class OrphanSnapshotTest { + + private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + } + + @DisplayName("should fail the build when failOnOrphans=true") + @Test + void orphanSnapshotsShouldFailTheBuild(TestInfo testInfo) throws IOException { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get(), true); + FakeObject fakeObject1 = FakeObject.builder().id("anyId1").value(1).name("anyName1").build(); + final Path snapshotFile = + Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/OrphanSnapshotTest.snap"); + + long bytesBefore = Files.size(snapshotFile); + + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(fakeObject1); + + Throwable exceptionThatWasThrown = + assertThrows( + SnapshotMatchException.class, + () -> { + snapshotVerifier.validateSnapshots(); + }); + + assertThat(exceptionThatWasThrown.getMessage()).isEqualTo("ERROR: Found orphan snapshots"); + + // Ensure file has not changed + long bytesAfter = Files.size(snapshotFile); + assertThat(bytesAfter).isGreaterThan(bytesBefore); + } + + @DisplayName("should not fail the build when failOnOrphans=false") + @Test + void orphanSnapshotsShouldNotFailTheBuild(TestInfo testInfo) throws IOException { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get(), false); + FakeObject fakeObject1 = FakeObject.builder().id("anyId1").value(1).name("anyName1").build(); + final Path snapshotFile = + Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/OrphanSnapshotTest.snap"); + + long bytesBefore = Files.size(snapshotFile); + + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(fakeObject1); + + snapshotVerifier.validateSnapshots(); + + // Ensure file has not changed + long bytesAfter = Files.size(snapshotFile); + assertThat(bytesAfter).isGreaterThan(bytesBefore); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java new file mode 100644 index 0000000..01b067d --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java @@ -0,0 +1,24 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +class PrivateCalledMethodTest { + + @Test + void testName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + testBasedOnArgs("testContent", testInfo); + snapshotVerifier.validateSnapshots(); + } + + private void testBasedOnArgs(String arg, TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(arg); + snapshotVerifier.validateSnapshots(); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java new file mode 100644 index 0000000..9cb126d --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java @@ -0,0 +1,31 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.exceptions.SnapshotMatchException; + +import java.lang.reflect.Method; +import java.util.Optional; +import java.util.stream.Stream; + +public class ReflectionUtilities { + + // FIXME consider guava reflection instead + public static Method getMethod(Class clazz, String methodName) { + try { + return Stream.of(clazz.getDeclaredMethods()) + .filter(method -> method.getName().equals(methodName)) + .findFirst() + .orElseThrow(() -> new NoSuchMethodException("Not Found")); + } catch (NoSuchMethodException e) { + return Optional.ofNullable(clazz.getSuperclass()) + .map(superclass -> getMethod(superclass, methodName)) + .orElseThrow( + () -> + new SnapshotMatchException( + "Could not find method " + + methodName + + " on class " + + clazz + + "\nPlease annotate your test method with @Test and make it without any parameters!")); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java new file mode 100644 index 0000000..e861964 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java @@ -0,0 +1,56 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +class ScenarioTest { + + private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); + + @Test + void canTakeMultipleSnapshotsUsingScenario(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Default Snapshot"); + expect.scenario("additional").toMatchSnapshot("Additional Snapshot"); + snapshotVerifier.validateSnapshots(); + } + + @Test + void canTakeTheSameSnapshotTwice(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Default Snapshot"); + expect.toMatchSnapshot("Default Snapshot"); + expect.scenario("scenario").toMatchSnapshot("Scenario Snapshot"); + expect.scenario("scenario").toMatchSnapshot("Scenario Snapshot"); + snapshotVerifier.validateSnapshots(); + } + + @Test + void cannotTakeDifferentSnapshotsAtDefaultLevel(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Default Snapshot"); + assertThrows(SnapshotMatchException.class, () -> expect.toMatchSnapshot("Default Snapshot 2")); + } + + @Test + void cannotTakeDifferentSnapshotsAtScenarioLevel(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.scenario("scenario").toMatchSnapshot("Default Snapshot"); + assertThrows( + SnapshotMatchException.class, + () -> expect.scenario("scenario").toMatchSnapshot("Default Snapshot 2")); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java new file mode 100644 index 0000000..42b9b91 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java @@ -0,0 +1,105 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.exceptions.SnapshotExtensionException; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; + +class SnapshotCaptor { + + private Class parameterClass; + + private Class argumentClass; + + private String[] ignore; + + public SnapshotCaptor(Class parameterClass, String... ignore) { + this.parameterClass = parameterClass; + this.argumentClass = parameterClass; + this.ignore = ignore; + } + + public SnapshotCaptor(Class parameterClass, Class argumentClass, String... ignore) { + this.parameterClass = parameterClass; + this.argumentClass = argumentClass; + this.ignore = ignore; + } + + public Class getParameterClass() { + return parameterClass; + } + + public Object removeIgnored(Object value) { + Object newValue = value; + if (ignore != null && ignore.length > 0) { + newValue = shallowCopy(value); + for (String each : ignore) { + try { + Field field = this.argumentClass.getDeclaredField(each); + field.setAccessible(true); + if (field.getType().isPrimitive()) { + field.setByte(newValue, Integer.valueOf(0).byteValue()); + } else { + field.set(newValue, null); + } + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new SnapshotExtensionException("Invalid Ignore value " + each, e.getCause()); + } + } + } + return newValue; + } + + private Object shallowCopy(Object value) { + try { + Object newValue = constructCopy(this.argumentClass); + + Field[] fields = this.argumentClass.getDeclaredFields(); + + for (Field field : fields) { + field.setAccessible(true); + try { + field.set(newValue, field.get(value)); + } catch (Exception e) { + // ignore + } + } + return newValue; + } catch (Exception e) { + throw new SnapshotExtensionException( + "Class " + + this.argumentClass.getSimpleName() + + " must have a default empty constructor!"); + } + } + + private Object constructCopy(Class argumentClass) + throws InstantiationException, IllegalAccessException, + java.lang.reflect.InvocationTargetException, NoSuchMethodException { + + try { + return argumentClass.getDeclaredConstructor().newInstance(); + } catch (Exception e) { + // Ignore - should log + } + + Constructor[] constructors = argumentClass.getDeclaredConstructors(); + + if (constructors.length == 0) { + return argumentClass.getDeclaredConstructor().newInstance(); + } + + int i = 0; + Class[] types = constructors[i].getParameterTypes(); + Object[] paramValues = new Object[types.length]; + + for (int j = 0; j < types.length; j++) { + if (types[j].isPrimitive()) { + paramValues[j] = Integer.valueOf(0).byteValue(); + } else { + paramValues[j] = constructCopy(types[j]); + } + } + return constructors[i].newInstance(paramValues); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java new file mode 100644 index 0000000..e35dd5e --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java @@ -0,0 +1,231 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +import lombok.SneakyThrows; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.opentest4j.AssertionFailedError; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@ExtendWith(MockitoExtension.class) +class SnapshotContextTest { + + private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); + private static final String FILE_PATH = "src/test/java/anyFilePath"; + private static final String SNAPSHOT_NAME = "java.lang.String.toString"; + private static final String SNAPSHOT = "java.lang.String.toString=[\nanyObject\n]"; + + private SnapshotFile snapshotFile; + + private SnapshotContext snapshotContext; + + @BeforeEach + void setUp() throws NoSuchMethodException, IOException { + snapshotFile = + new SnapshotFile(DEFAULT_CONFIG.getOutputDir(), "anyFilePath", SnapshotContextTest.class); + snapshotContext = + new SnapshotContext( + DEFAULT_CONFIG, + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + "anyObject"); + } + + @AfterEach + void tearDown() throws IOException { + Files.deleteIfExists(Paths.get(FILE_PATH)); + } + + @Test + void shouldGetSnapshotNameSuccessfully() { + String snapshotName = snapshotContext.resolveSnapshotIdentifier(); + assertThat(snapshotName).isEqualTo(SNAPSHOT_NAME); + } + + @Test + void shouldMatchSnapshotSuccessfully() { + snapshotContext.toMatchSnapshot(); + assertThat(snapshotFile.getSnapshots().stream().findFirst().get().raw()).isEqualTo(SNAPSHOT); + } + + @Test + void shouldMatchSnapshotWithException() { + snapshotFile.pushSnapshot(Snapshot.parse(SNAPSHOT_NAME + "=anyWrongSnapshot")); + assertThrows(SnapshotMatchException.class, snapshotContext::toMatchSnapshot); + } + + @SneakyThrows + @Test + void shouldRenderScenarioNameWhenSupplied() { + SnapshotContext snapshotContextWithScenario = + new SnapshotContext( + DEFAULT_CONFIG, + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + "anyObject"); + snapshotContextWithScenario.setScenario("hello world"); + assertThat(snapshotContextWithScenario.resolveSnapshotIdentifier()) + .isEqualTo("java.lang.String.toString[hello world]"); + } + + @SneakyThrows + @Test + void shouldNotRenderScenarioNameWhenNull() { + SnapshotContext snapshotContextWithoutScenario = + new SnapshotContext( + DEFAULT_CONFIG, + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + "anyObject"); + assertThat(snapshotContextWithoutScenario.resolveSnapshotIdentifier()) + .isEqualTo("java.lang.String.toString"); + } + + @SneakyThrows + @Test + void shouldOverwriteSnapshotsWhenParamIsPassed() { + SnapshotConfig mockConfig = Mockito.mock(SnapshotConfig.class); + Mockito.when(mockConfig.updateSnapshot()).thenReturn(Optional.of("")); + Mockito.when(mockConfig.getSerializer()).thenReturn(new ToStringSnapshotSerializer()); + SnapshotFile snapshotFile = Mockito.mock(SnapshotFile.class); + Set set = new HashSet<>(); + set.add(Snapshot.parse("java.lang.String.toString[hello world]=[{" + "\"a\": \"b\"" + "}]")); + Mockito.when(snapshotFile.getSnapshots()).thenReturn(set); + + SnapshotContext snapshotContext = + new SnapshotContext( + mockConfig, + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + "anyObject"); + snapshotContext.setScenario("hello world"); + snapshotContext.toMatchSnapshot(); + Mockito.verify(snapshotFile) + .pushSnapshot(Snapshot.parse("java.lang.String.toString[hello world]=[\nanyObject\n]")); + } + + @SneakyThrows + @Test + void shouldFailWhenRunningOnCiWithoutExistingSnapshot() { + BaseSnapshotConfig ciSnapshotConfig = + new BaseSnapshotConfig() { + @Override + public boolean isCI() { + return true; + } + }; + + SnapshotContext ciSnapshotContext = + new SnapshotContext( + ciSnapshotConfig, + new SnapshotFile(ciSnapshotConfig.getOutputDir(), "blah", SnapshotContextTest.class), + String.class, + String.class.getDeclaredMethod("toString"), + "anyObject"); + + Assertions.assertThatThrownBy(ciSnapshotContext::toMatchSnapshot) + .hasMessage( + "Snapshot [java.lang.String.toString] not found. Has this snapshot been committed ?"); + } + + @SneakyThrows + @Test + void shouldAggregateMultipleFailures() { + SnapshotFile snapshotFile = Mockito.mock(SnapshotFile.class); + Set set = new HashSet<>(); + set.add(Snapshot.parse("java.lang.String.toString=[\n \"hello\"\n]")); + Mockito.when(snapshotFile.getSnapshots()).thenReturn(set); + + Stream> reportingFunctions = + Stream.of( + (rawSnapshot, currentObject) -> + assertThat(currentObject).isEqualTo(rawSnapshot), // assertj + org.junit.jupiter.api.Assertions::assertEquals, // junit jupiter + (previous, current) -> { + String message = + String.join( + System.lineSeparator(), + "Expected : ", + previous.raw(), + "Actual : ", + current.raw()); + throw new AssertionFailedError(message, previous, current); // opentest4j + }); + + Stream reporters = + reportingFunctions.map( + consumer -> + new SnapshotReporter() { + @Override + public boolean supportsFormat(String outputFormat) { + return true; + } + + @Override + public void report(Snapshot previous, Snapshot current) { + consumer.accept(previous, current); + } + }); + + SnapshotContext failingSnapshotContext = + new SnapshotContext( + DEFAULT_CONFIG, + snapshotFile, + String.class, + String.class.getDeclaredMethod("toString"), + "hola"); + failingSnapshotContext.setSnapshotSerializer(new ToStringSnapshotSerializer()); + failingSnapshotContext.setSnapshotReporters(reporters.collect(Collectors.toList())); + + try { + failingSnapshotContext.toMatchSnapshot(); + } catch (Throwable m) { + String cleanMessage = + m.getMessage() + .replace("<\"", "") + .replace("<", "") + .replaceAll("\n", "") + .replaceAll("\r", "") + .replaceAll("\t", "") + .replace("\">", " ") + .replace(">", " ") + .replace("]", "") + .replace("java.lang.String.toString=[", "") + .replaceAll(" +", " "); + + assertThat(cleanMessage) + .containsPattern("Expecting.*hola.*to be equal to.*hello.*but was not"); // assertj + assertThat(cleanMessage).containsPattern("expected.*hello.*but was.*hola"); // junit jupiter + assertThat(cleanMessage).containsPattern("Expected.*hello.*Actual.*hola"); // opentest4j + + return; + } + + Assertions.fail("Expected an error to be thrown"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java new file mode 100644 index 0000000..c5cec1f --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java @@ -0,0 +1,59 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.serializers.LowercaseToStringSerializer; +import au.com.origin.snapshots.serializers.SerializerType; +import lombok.NoArgsConstructor; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class SnapshotHeaders { + + private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); + + static SnapshotVerifier snapshotVerifier; + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + snapshotVerifier = new SnapshotVerifier(DEFAULT_CONFIG, SnapshotHeaders.class); + } + + @AfterAll + static void afterAll() { + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldBeAbleToSnapshotASingleCustomHeader(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer(CustomHeadersSerializer.class).toMatchSnapshot("Hello World"); + } + + @Test + void shouldBeAbleToSnapshotMultipleCustomHeader(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer(CustomHeadersSerializer.class).toMatchSnapshot("Hello World"); + } + + @NoArgsConstructor + private static class CustomHeadersSerializer extends LowercaseToStringSerializer { + @Override + public String getOutputFormat() { + return SerializerType.JSON.name(); + } + + @Override + public Snapshot apply(Object object, SnapshotSerializerContext snapshotSerializerContext) { + snapshotSerializerContext.getHeader().put("custom", "anything"); + snapshotSerializerContext.getHeader().put("custom2", "anything2"); + return super.apply(object, snapshotSerializerContext); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java new file mode 100644 index 0000000..bc48e50 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java @@ -0,0 +1,93 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import au.com.origin.snapshots.serializers.UppercaseToStringSerializer; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +@ExtendWith(MockitoExtension.class) +public class SnapshotIntegrationTest { + + private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); + + static SnapshotVerifier snapshotVerifier; + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + snapshotVerifier = new SnapshotVerifier(DEFAULT_CONFIG, SnapshotIntegrationTest.class); + } + + @AfterAll + static void afterAll() { + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldMatchSnapshotOne(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(FakeObject.builder().id("anyId1").value(1).name("anyName1").build()); + } + + @Test + void shouldMatchSnapshotTwo(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(FakeObject.builder().id("anyId2").value(2).name("anyName2").build()); + } + + @Test + void shouldMatchSnapshotThree(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(FakeObject.builder().id("anyId3").value(3).name("anyName3").build()); + } + + @Test + void shouldMatchSnapshotFour(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot( + FakeObject.builder().id("anyId4").value(4).name("any\n\n\nName4").build()); + } + + @Test + void shouldMatchSnapshotInsidePrivateMethod(TestInfo testInfo) { + matchInsidePrivate(testInfo); + } + + @Test + void shouldThrowSnapshotMatchException(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows( + SnapshotMatchException.class, + () -> + expect.toMatchSnapshot( + FakeObject.builder().id("anyId5").value(6).name("anyName5").build()), + "Error on: \n" + + "au.com.origin.snapshots.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=["); + } + + @Test + void shouldSnapshotUsingSerializerClass(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer(UppercaseToStringSerializer.class).toMatchSnapshot("Hello World"); + } + + @Test + void shouldSnapshotUsingSerializerPropertyName(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer("lowercase").toMatchSnapshot("Hello World"); + } + + private void matchInsidePrivate(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot( + FakeObject.builder().id("anyPrivate").value(5).name("anyPrivate").build()); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java new file mode 100644 index 0000000..a74f93a --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java @@ -0,0 +1,66 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; + +@ExtendWith(MockitoExtension.class) +class SnapshotMatcherScenarioTest { + + private static final String FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotMatcherScenarioTest.snap"; + + static SnapshotVerifier snapshotVerifier; + + @BeforeAll + static void beforeAll() { + snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), SnapshotMatcherScenarioTest.class); + } + + @AfterAll + static void afterAll() throws IOException { + snapshotVerifier.validateSnapshots(); + File f = new File(FILE_PATH); + assertThat(String.join("\n", Files.readAllLines(f.toPath()))) + .isEqualTo( + "au.com.origin.snapshots.SnapshotMatcherScenarioTest.should1ShowSnapshotSuccessfully[Scenario A]=[\n" + + "any type of object\n" + + "]\n\n\n" + + "au.com.origin.snapshots.SnapshotMatcherScenarioTest.should2SecondSnapshotExecutionSuccessfully[Scenario B]=[\n" + + "any second type of object\n" + + "]"); + Files.delete(Paths.get(FILE_PATH)); + } + + @Test + void should1ShowSnapshotSuccessfully(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.scenario("Scenario A").toMatchSnapshot("any type of object"); + File f = new File(FILE_PATH); + if (!f.exists() || f.isDirectory()) { + throw new RuntimeException("File should exist here"); + } + } + + @Test + void should2SecondSnapshotExecutionSuccessfully(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.scenario("Scenario B").toMatchSnapshot("any second type of object"); + File f = new File(FILE_PATH); + if (!f.exists() || f.isDirectory()) { + throw new RuntimeException("File should exist here"); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java new file mode 100644 index 0000000..7871004 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java @@ -0,0 +1,65 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; + +@ExtendWith(MockitoExtension.class) +class SnapshotMatcherTest { + + private static final String FILE_PATH = + "src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotMatcherTest.snap"; + + static SnapshotVerifier snapshotVerifier; + + @BeforeAll + static void beforeAll() { + snapshotVerifier = new SnapshotVerifier(new BaseSnapshotConfig(), SnapshotMatcherTest.class); + } + + @AfterAll + static void afterAll() throws IOException { + snapshotVerifier.validateSnapshots(); + File f = new File(FILE_PATH); + assertThat(String.join("\n", Files.readAllLines(f.toPath()))) + .isEqualTo( + "au.com.origin.snapshots.SnapshotMatcherTest.should1ShowSnapshotSuccessfully=[\n" + + "any type of object\n" + + "]\n\n\n" + + "au.com.origin.snapshots.SnapshotMatcherTest.should2SecondSnapshotExecutionSuccessfully=[\n" + + "any second type of object\n" + + "]"); + Files.delete(Paths.get(FILE_PATH)); + } + + @Test + void should1ShowSnapshotSuccessfully(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("any type of object"); + File f = new File(FILE_PATH); + if (!f.exists() || f.isDirectory()) { + throw new RuntimeException("File should exist here"); + } + } + + @Test + void should2SecondSnapshotExecutionSuccessfully(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("any second type of object"); + File f = new File(FILE_PATH); + if (!f.exists() || f.isDirectory()) { + throw new RuntimeException("File should exist here"); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java new file mode 100644 index 0000000..08c8600 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java @@ -0,0 +1,95 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.annotations.SnapshotName; +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.exceptions.ReservedWordException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class SnapshotNameAnnotationTest { + + @BeforeEach + void beforeEach() { + SnapshotUtils.copyTestSnapshots(); + } + + @SnapshotName("can_use_snapshot_name") + @Test + void canUseSnapshotNameAnnotation(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Hello World"); + snapshotVerifier.validateSnapshots(); + } + + @SnapshotName("can use snapshot name with spaces") + @Test + void canUseSnapshotNameAnnotationWithSpaces(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Hello World"); + snapshotVerifier.validateSnapshots(); + } + + @SnapshotName("can't use '=' character in snapshot name") + @Test + void cannotUseEqualsInsideSnapshotName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows(ReservedWordException.class, () -> expect.toMatchSnapshot("FooBar")); + } + + @SnapshotName("can't use '[' character in snapshot name") + @Test + void cannotUseOpeningSquareBracketInsideSnapshotName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows(ReservedWordException.class, () -> expect.toMatchSnapshot("FooBar")); + } + + @SnapshotName("can't use ']' character in snapshot name") + @Test + void cannotUseClosingSquareBracketInsideSnapshotName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows(ReservedWordException.class, () -> expect.toMatchSnapshot("FooBar")); + } + + @Test + void cannotUseEqualsInsideScenarioName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows( + ReservedWordException.class, + () -> expect.scenario("can't use = symbol in scenario").toMatchSnapshot("FooBar")); + } + + @Test + void cannotUseOpeningSquareBracketInsideScenarioName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows( + ReservedWordException.class, + () -> expect.scenario("can't use [ symbol in scenario").toMatchSnapshot("FooBar")); + } + + @Test + void cannotUseClosingSquareBracketInsideScenarioName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows( + ReservedWordException.class, + () -> expect.scenario("can't use ] symbol in scenario").toMatchSnapshot("FooBar")); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java new file mode 100644 index 0000000..a7e2923 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java @@ -0,0 +1,25 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.annotations.SnapshotName; +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotExtensionException; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class SnapshotNameAnnotationWithDuplicatesTest { + + @SnapshotName("hello_world") + @Test + void canUseSnapshotNameAnnotation(TestInfo testInfo) { + assertThrows( + SnapshotExtensionException.class, + () -> new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()), + "Oops, looks like you set the same name of two separate snapshots @SnapshotName(\"hello_world\") in class au.com.origin.snapshots.SnapshotNameAnnotationTest"); + } + + @SnapshotName("hello_world") + private void anotherMethodWithSameSnapshotName() { + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java new file mode 100644 index 0000000..48e7544 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java @@ -0,0 +1,24 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +public class SnapshotOverrideClassTest extends SnapshotSuperClassTest { + + @BeforeEach + void beforeEach() { + snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), SnapshotOverrideClassTest.class); + } + + @AfterEach + void afterEach() { + snapshotVerifier.validateSnapshots(); + } + + @Override + public String getName() { + return "anyName"; + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java new file mode 100644 index 0000000..8a358c5 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java @@ -0,0 +1,20 @@ +package au.com.origin.snapshots; + +import lombok.Getter; +import lombok.Setter; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +public abstract class SnapshotSuperClassTest { + + @Getter + @Setter + static SnapshotVerifier snapshotVerifier; + + public abstract String getName(); + + @Test + void shouldMatchSnapshotOne(TestInfo testInfo) { + Expect.of(snapshotVerifier, testInfo.getTestMethod().get()).toMatchSnapshot(getName()); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java new file mode 100644 index 0000000..8d14d31 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java @@ -0,0 +1,95 @@ +package au.com.origin.snapshots; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.entry; + +class SnapshotTest { + + @Test + public void shouldParseSnapshot() { + Snapshot snapshot = + Snapshot.parse( + Snapshot.builder().name("au.com.origin.snapshots.Test").body("body").build().raw()); + assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getHeader()).isEmpty(); + assertThat(snapshot.getScenario()).isBlank(); + assertThat(snapshot.getBody()).isEqualTo("body"); + } + + @Test + public void shouldParseSnapshotWithHeaders() { + SnapshotHeader header = new SnapshotHeader(); + header.put("header1", "value1"); + Snapshot snapshot = + Snapshot.parse( + Snapshot.builder() + .name("au.com.origin.snapshots.Test") + .header(header) + .body("body") + .build() + .raw()); + assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getHeader()).containsExactly(entry("header1", "value1")); + assertThat(snapshot.getScenario()).isBlank(); + assertThat(snapshot.getBody()).isEqualTo("body"); + } + + @Test + public void shouldParseSnapshotWithScenario() { + Snapshot snapshot = + Snapshot.parse( + Snapshot.builder() + .name("au.com.origin.snapshots.Test") + .scenario("scenario") + .body("body") + .build() + .raw()); + assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); + assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getHeader()).isEmpty(); + assertThat(snapshot.getScenario()).isEqualTo("scenario"); + assertThat(snapshot.getBody()).isEqualTo("body"); + } + + @Test + public void shouldParseSnapshotWithScenarioAndHeaders() { + SnapshotHeader header = new SnapshotHeader(); + header.put("header1", "value1"); + Snapshot snapshot = + Snapshot.parse( + Snapshot.builder() + .name("au.com.origin.snapshots.Test") + .scenario("scenario") + .header(header) + .body("body") + .build() + .raw()); + assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); + assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getHeader()).containsExactly(entry("header1", "value1")); + assertThat(snapshot.getScenario()).isEqualTo("scenario"); + assertThat(snapshot.getBody()).isEqualTo("body"); + } + + @Test + public void + shouldParseSnapshotWithScenarioAndBodyWithSomethingSimilarToAnScenarioToConfuseRegex() { + Snapshot snapshot = + Snapshot.parse( + Snapshot.builder() + .name("au.com.origin.snapshots.Test") + .scenario("scenario") + .body("[xxx]=yyy") + .build() + .raw()); + assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); + assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getHeader()).isEmpty(); + assertThat(snapshot.getScenario()).isEqualTo("scenario"); + assertThat(snapshot.getBody()).isEqualTo("[xxx]=yyy"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java new file mode 100644 index 0000000..47b77fd --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java @@ -0,0 +1,106 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import org.apache.commons.io.FileUtils; +import org.mockito.ArgumentCaptor; + +import java.io.IOException; +import java.lang.reflect.Parameter; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.verify; + +public class SnapshotUtils { + + public static HashMap>> extractArgs( + T object, String methodName, SnapshotCaptor... snapshotCaptors) { + List captors = new ArrayList<>(); + Class[] classes = new Class[snapshotCaptors.length]; + + int i = 0; + for (SnapshotCaptor snapshotCaptor : snapshotCaptors) { + classes[i] = snapshotCaptor.getParameterClass(); + captors.add(ArgumentCaptor.forClass(snapshotCaptor.getParameterClass())); + i++; + } + + return process(object, methodName, captors, classes, snapshotCaptors); + } + + public static HashMap>> extractArgs( + T object, String methodName, Class... classes) { + List captors = new ArrayList<>(); + + for (Class clazz : classes) { + captors.add(ArgumentCaptor.forClass(clazz)); + } + + return process(object, methodName, captors, classes, null); + } + + private static HashMap>> process( + T object, + String methodName, + List captors, + Class[] classes, + SnapshotCaptor[] snapshotCaptors) { + HashMap>> result = new HashMap<>(); + try { + Parameter[] parameters = + object.getClass().getDeclaredMethod(methodName, classes).getParameters(); + + object + .getClass() + .getDeclaredMethod(methodName, classes) + .invoke( + verify(object, atLeastOnce()), + captors.stream().map(ArgumentCaptor::capture).toArray()); + + List> extractedObjects = new ArrayList<>(); + + int numberOfCall; + + if (captors.size() > 0) { + numberOfCall = captors.get(0).getAllValues().size(); + + for (int i = 0; i < numberOfCall; i++) { + LinkedHashMap objectMap = new LinkedHashMap<>(); + + int j = 0; + for (ArgumentCaptor captor : captors) { + Object value = captor.getAllValues().get(i); + if (snapshotCaptors != null) { + value = snapshotCaptors[j].removeIgnored(value); + } + objectMap.put(parameters[j].getName(), value); + j++; + } + extractedObjects.add(objectMap); + } + } + + result.put( + object.getClass().getSuperclass().getSimpleName() + "." + methodName, extractedObjects); + } catch (Exception e) { + throw new SnapshotMatchException(e.getMessage(), e.getCause()); + } + + return result; + } + + public static void copyTestSnapshots() { + try { + FileUtils.copyDirectory( + Paths.get("src/test/java/au/com/origin/snapshots/existing-snapshots").toFile(), + Paths.get("src/test/java/au/com/origin/snapshots").toFile()); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException("Can't move files to __snapshots__ folder"); + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java new file mode 100644 index 0000000..231f880 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java @@ -0,0 +1,77 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.Arrays; +import java.util.List; + +import static au.com.origin.snapshots.SnapshotUtils.extractArgs; + +@ExtendWith(MockitoExtension.class) +class SnapshotUtilsTest { + + @Mock + private FakeObject fakeObject; + + @Test + void shouldExtractArgsFromFakeMethod(TestInfo testInfo) { + fakeObject.fakeMethod("test1", 1L, Arrays.asList("listTest1")); + fakeObject.fakeMethod("test2", 2L, Arrays.asList("listTest1", "listTest2")); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot( + extractArgs( + fakeObject, + "fakeMethod", + new SnapshotCaptor(String.class), + new SnapshotCaptor(Long.class), + new SnapshotCaptor(List.class))); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldExtractArgsFromFakeMethodWithComplexObject(TestInfo testInfo) { + FakeObject fake = new FakeObject.FakeObjectBuilder().id("idMock").name("nameMock").build(); + + // With Ignore + fakeObject.fakeMethodWithComplexFakeObject(fake); + Object fakeMethodWithComplexObjectWithIgnore = + extractArgs( + fakeObject, + "fakeMethodWithComplexFakeObject", + new SnapshotCaptor(FakeObject.class, "name")); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(fakeMethodWithComplexObjectWithIgnore); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldExtractArgsFromFakeMethodWithComplexFakeObject(TestInfo testInfo) { + + FakeObject fake = new FakeObject.FakeObjectBuilder().id("idMock").name("nameMock").build(); + + // With Ignore + fakeObject.fakeMethodWithComplexObject(fake); + Object fakeMethodWithComplexObjectWithIgnore = + extractArgs( + fakeObject, + "fakeMethodWithComplexObject", + new SnapshotCaptor(Object.class, FakeObject.class, "name")); + + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(fakeMethodWithComplexObjectWithIgnore); + snapshotVerifier.validateSnapshots(); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java new file mode 100644 index 0000000..91caacd --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java @@ -0,0 +1,94 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +@Deprecated +@ExtendWith(MockitoExtension.class) +public class UpdateSnapshotPropertyTest { + + @AfterAll + static void afterAll() { + System.clearProperty(SnapshotConfig.JVM_UPDATE_SNAPSHOTS_PARAMETER); + } + + @BeforeEach + public void beforeEach() throws Exception { + File file = + new File( + "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap"); + String content = + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" + + "FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null)\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" + + "FakeObject(id=ERROR, value=2, name=anyName2, fakeObject=null)\n" + + "]"; + Path parentDir = file.getParentFile().toPath(); + if (!Files.exists(parentDir)) { + Files.createDirectories(parentDir); + } + Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8)); + } + + @Test + void shouldUpdateSnapshot(TestInfo testInfo) throws IOException { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get(), false); + System.setProperty(SnapshotConfig.JVM_UPDATE_SNAPSHOTS_PARAMETER, ""); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(FakeObject.builder().id("anyId2").value(2).name("anyName2").build()); + snapshotVerifier.validateSnapshots(); + + String content = + new String( + Files.readAllBytes( + Paths.get( + "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap")), + StandardCharsets.UTF_8); + Assertions.assertThat(content) + .isEqualTo( + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" + + "FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null)\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" + + "FakeObject(id=anyId2, value=2, name=anyName2, fakeObject=null)\n" + + "]"); + } + + @Test + void shouldNotUpdateSnapshot(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get(), false); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + System.setProperty(SnapshotConfig.JVM_UPDATE_SNAPSHOTS_PARAMETER, "true"); + assertThrows( + SnapshotMatchException.class, + () -> + expect.toMatchSnapshot( + FakeObject.builder().id("anyId1").value(1).name("anyName1").build()), + "Error on: \n" + + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=["); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java new file mode 100644 index 0000000..1dd2a45 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java @@ -0,0 +1,154 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +@ExtendWith(MockitoExtension.class) +public class UpdateSnapshotTest { + + @BeforeEach + public void beforeEach() throws Exception { + File file = + new File("src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap"); + String content = + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + + "OLD\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + + "OLD\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + + "OLD\n" + + "]"; + Path parentDir = file.getParentFile().toPath(); + if (!Files.exists(parentDir)) { + Files.createDirectories(parentDir); + } + Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8)); + } + + @Test + void canUpdateAllSnapshots(TestInfo testInfo) throws IOException { + SnapshotConfig config = + new BaseSnapshotConfig() { + @Override + public Optional updateSnapshot() { + return Optional.of(""); + } + }; + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(config, testInfo.getTestClass().get(), false); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("NEW"); + snapshotVerifier.validateSnapshots(); + + String content = + new String( + Files.readAllBytes( + Paths.get( + "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap")), + StandardCharsets.UTF_8); + Assertions.assertThat(content) + .isEqualTo( + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + + "NEW\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + + "OLD\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + + "OLD\n" + + "]"); + } + + @Test + void canUpdateNoSnapshots(TestInfo testInfo) { + SnapshotConfig config = + new BaseSnapshotConfig() { + @Override + public Optional updateSnapshot() { + return Optional.empty(); + } + }; + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(config, testInfo.getTestClass().get(), false); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + assertThrows(SnapshotMatchException.class, () -> expect.toMatchSnapshot("FOOBAR")); + } + + @Test + public void canUpdateNewSnapshots() { + SnapshotConfig config = + new BaseSnapshotConfig() { + @Override + public Optional updateSnapshot() { + return Optional.of("new"); + } + }; + + // TODO Pending Implementation + } + + @Test + public void canUpdateClassNameSnapshots(TestInfo testInfo) throws IOException { + SnapshotConfig config = + new BaseSnapshotConfig() { + @Override + public Optional updateSnapshot() { + return Optional.of("UpdateSnapshotTest"); + } + }; + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(config, testInfo.getTestClass().get(), false); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("NEW"); + snapshotVerifier.validateSnapshots(); + + String content = + new String( + Files.readAllBytes( + Paths.get( + "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap")), + StandardCharsets.UTF_8); + Assertions.assertThat(content) + .isEqualTo( + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + + "OLD\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + + "NEW\n" + + "]\n" + + "\n" + + "\n" + + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + + "OLD\n" + + "]"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java new file mode 100644 index 0000000..82f2a07 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java @@ -0,0 +1,39 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.annotations.UseSnapshotConfig; +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.config.ToStringSnapshotConfig; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@UseSnapshotConfig(ToStringSnapshotConfig.class) +@ExtendWith(MockitoExtension.class) +public class UseCustomConfigTest { + + private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); + + @BeforeAll + static void beforeAll() { + SnapshotUtils.copyTestSnapshots(); + } + + @Test + void canUseSnapshotConfigAnnotationAtClassLevel(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(new TestObject()); + snapshotVerifier.validateSnapshots(); + } + + private class TestObject { + @Override + public String toString() { + return "This is a snapshot of the toString() method"; + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java new file mode 100644 index 0000000..5ff4abb --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java @@ -0,0 +1,49 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.config.BaseSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.serializers.UppercaseToStringSerializer; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class UseCustomSerializerTest { + + private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); + + @BeforeAll + static void beforeEach() { + SnapshotUtils.copyTestSnapshots(); + } + + @DisplayName("@SnapshotSerializer on a method via new instance") + @Test + public void canUseSnapshotSerializerAnnotationAtMethodLevelUsingNewInstance(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer(new UppercaseToStringSerializer()).toMatchSnapshot(new TestObject()); + snapshotVerifier.validateSnapshots(); + } + + @DisplayName("@SnapshotSerializer on a method via class name") + @Test + public void canUseSnapshotSerializerAnnotationAtMethodLevelUsingClassName(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer(new UppercaseToStringSerializer()).toMatchSnapshot(new TestObject()); + snapshotVerifier.validateSnapshots(); + } + + private class TestObject { + @Override + public String toString() { + return "This is a snapshot of the toString() method"; + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java new file mode 100644 index 0000000..8e1b664 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java @@ -0,0 +1,24 @@ +package au.com.origin.snapshots.comparators; + +import au.com.origin.snapshots.Snapshot; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class PlainTextEqualsComparatorTest { + + private static final PlainTextEqualsComparator COMPARATOR = new PlainTextEqualsComparator(); + + @Test + void successfulComparison() { + Snapshot snap1 = Snapshot.builder().name("snap1").scenario("A").body("foo").build(); + Snapshot snap2 = Snapshot.builder().name("snap1").scenario("A").body("foo").build(); + Assertions.assertThat(COMPARATOR.matches(snap1, snap2)).isTrue(); + } + + @Test + void failingComparison() { + Snapshot snap1 = Snapshot.builder().name("snap1").scenario("A").body("foo").build(); + Snapshot snap2 = Snapshot.builder().name("snap1").scenario("A").body("bar").build(); + Assertions.assertThat(COMPARATOR.matches(snap1, snap2)).isFalse(); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java new file mode 100644 index 0000000..210a751 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java @@ -0,0 +1,44 @@ +package au.com.origin.snapshots.config; + +import au.com.origin.snapshots.comparators.PlainTextEqualsComparator; +import au.com.origin.snapshots.comparators.SnapshotComparator; +import au.com.origin.snapshots.reporters.PlainTextSnapshotReporter; +import au.com.origin.snapshots.reporters.SnapshotReporter; +import au.com.origin.snapshots.serializers.SnapshotSerializer; +import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; + +import java.util.Collections; +import java.util.List; + +public class BaseSnapshotConfig implements SnapshotConfig { + + @Override + public String getOutputDir() { + return "src/test/java"; + } + + @Override + public String getSnapshotDir() { + return "__snapshots__"; + } + + @Override + public SnapshotSerializer getSerializer() { + return new ToStringSnapshotSerializer(); + } + + @Override + public SnapshotComparator getComparator() { + return new PlainTextEqualsComparator(); + } + + @Override + public List getReporters() { + return Collections.singletonList(new PlainTextSnapshotReporter()); + } + + @Override + public boolean isCI() { + return false; + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java new file mode 100644 index 0000000..5c06e67 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java @@ -0,0 +1,24 @@ +package au.com.origin.snapshots.config; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; + +public class ToStringSnapshotConfig extends BaseSnapshotConfig { + + @Override + public SnapshotSerializer getSerializer() { + return new SnapshotSerializer() { + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } + + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + return gen.toSnapshot(object.toString()); + } + }; + } +} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/README.md b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/README.md similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/README.md rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/README.md diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap similarity index 100% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap rename to snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java new file mode 100644 index 0000000..bea19c6 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java @@ -0,0 +1,34 @@ +package au.com.origin.snapshots.reporters; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.serializers.SerializerType; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.opentest4j.AssertionFailedError; + +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +class PlainTextSnapshotReporterTest { + private static final PlainTextSnapshotReporter REPORTER = new PlainTextSnapshotReporter(); + + @Test + void shouldSupportAllFormats() { + Assertions.assertThat(REPORTER.supportsFormat(SerializerType.TEXT.name())).isTrue(); + Assertions.assertThat(REPORTER.supportsFormat(SerializerType.JSON.name())).isTrue(); + + Assertions.assertThat(REPORTER.supportsFormat("xml")).isTrue(); + Assertions.assertThat(REPORTER.supportsFormat("blah")).isTrue(); + } + + @Test + void doReport() { + Snapshot snap1 = Snapshot.builder().name("snap1").scenario("A").body("[\nfoo\n]").build(); + Snapshot snap2 = Snapshot.builder().name("snap1").scenario("A").body("[\nbar\n]").build(); + assertThatExceptionOfType(AssertionFailedError.class) + .isThrownBy(() -> REPORTER.report(snap1, snap2)) + .withMessageContaining("expecting:") + .withMessageContaining("[\"foo\"]") + .withMessageContaining("but was:") + .withMessageContaining("[\"bar\"]"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java new file mode 100644 index 0000000..57e4d5c --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java @@ -0,0 +1,55 @@ +package au.com.origin.snapshots.serializers; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotHeader; +import au.com.origin.snapshots.SnapshotSerializerContext; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.nio.file.Files; + +import static org.assertj.core.api.Assertions.assertThat; + +public class Base64SnapshotSerializerTest { + + private SnapshotSerializerContext mockSnapshotGenerator = + new SnapshotSerializerContext( + "base64Test", + null, + new SnapshotHeader(), + Base64SnapshotSerializerTest.class, + null // it's not used in these scenarios + ); + + @Test + void shouldSnapshotAByteArray() { + Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); + Snapshot result = serializer.apply("John Doe".getBytes(), mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\nSm9obiBEb2U=\n]"); + } + + @Test + void shouldSnapshotAnyString() { + Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); + Snapshot result = serializer.apply("John Doe", mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\nSm9obiBEb2U=\n]"); + } + + @Test + void shouldSnapshotAFile() throws Exception { + Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); + File f = new File("src/test/resources/origin-logo.png"); + byte[] content = Files.readAllBytes(f.toPath()); + + Snapshot result = serializer.apply(content, mockSnapshotGenerator); + assertThat(result.getBody()) + .isEqualTo( + "[\niVBORw0KGgoAAAANSUhEUgAAAFgAAABYCAIAAAD+96djAAAKaklEQVR4nOxce3BcVRk/59zX3t3N5p3m1UeaNLQ2adKaFhDp9MFD3j7Qoqhg1VHpjEMR7CgKyghVQKa24wzSUhQcxwGLU0TsH0AphQLSxKSQJm02aRrSvDbPfd/HOddZ2LLJZp/n3F0aJr/Zf7J77nd+95fvfN85537n8oZhgHkAgD5pAhcK5oUIY16IMOaFCGNeiDD4rPVEpiZ1p1PvceLhITIyQlwuw+c1FMVQFGAYUJKAJEFZ5oqKUUkJKlnAL63mq5dxxcXZoQczmj7xqEtrflc7fUprbSGuEQoLMC9fbFzN1y4X1zRx5RUZ4Hi+o0wIQdxu5Y0jyuuv6p0dwDz73JIqacMmaf0mrrDILJsfw2Qh9L7ewMF/KEdfA5pmotkZQEhcd6l801eE5StNtGqaEHrfWf8z+9T/vWuiCyQGv2Kl7datwoo6U6yZI4Ty9lH/M0/i4UEzKKUB5Mi1bvm2ZfMXAM8a9VmFwMODvn171LZmRh4s4BYusf/gTqF2BYsRBiEwDhw66H/2L6H890kDIiRddb3tlq3QYqG0QCcEcU96//iw9l4LXa8ZAle5KOeu+7lSmixLI4Tu7PTseZCMuij6yzSg1WbftkNsXJf2hekKob7X7Nn1AFA/+eEQF4iz3bbNsunatC5KTwjl7SPevY8CPWNzBPMg33y79YZbUm+fRtZR3n7N+6ffhaYJkIpadhE48GcIoXz9lhTbpyqE2vqW78lHAJwbKnwE//NPAQ7J13w1lcYpCaF1d3gf3wkMAtHckeFDBA7sR3kF0qWbk7ZMLgSZHPM98RAg2hzdu/D9dTcqKhGW1SduliRY4vER3/5H9K73zaaXXUhS3kNPI7sjQZOEQhDi3nOv3tmaEXLZBbdoWe5dDwMp7rwzkbsHj76on24NNZn7H9zf5Xt+b4KbjSsEHh8JHHwqlCM+LR/l2EvaqbjeHTdYBl96xtAVYHaagILIV63ga1bxC2tQSQVy5ENeABACTSN+Dx45hwfO6N3va10njIDP3K5DSeTgPuHuPwDExSAWM0boHzg9j90JDGIiCW5hjXTZdWLDZVC2J2+tKWr7u8obL+rOEyZyAABYv7FdWnfl7O9jC+F54j6987hZfaOSSutN3xdWrKW4VjvTHvjXftzbCYA5G1+oYEHuz/YCLnooxBBC73d6dv3YlH6hbJO/vE1adRngBXorhGi9J/1/f4yMDZnACQDrLdultdFOESNYKq89F4ouzIGaW1ids323tGYDkwof7tYKS+sc23cLK9eZkkGCh58DBCcRgkyNqu3H2DsTVl7suONRrrCMSYJpgLLdfvsvpctvZOdGxvq17ujQEy2E2vwyMDBjouJr19i/dS8QJbNUOE+Ws974Q8umLeypVG15Jcp2dMzQuo4zrqygLdf6xTtmRyOzIG/cop8+jgd7WIzoPW0AY8BF8ugMj8DjQ7ivg0lsBK03b+cKy1lYJoFosd76c2i1sfA0vOPa2RkLqBlC6M5mxuEnXnKdcBFNmkwLXEGZfMOPGKnqXc1xhdC6W1hMw/xi65W3ZVqFjyA2bOSrG1jYat3xhCAE97ax+Ju86ZtAsmZHiFCwuHpraAVAy5a4eolvMoYQeKzf0ALUAqPCMrF+Q9ZUCA2QshrhIoaZBQR4sCuWEENOpujQeEXmMkU8iE3XsnDGg86PTUWo4+EelsQp1K1nvq/0O61qRPY8wz9FdzkeieTgiEcQ9zD1eENFFVx+JlNmPHA8t6SePky4R2IIYXhc1D7GLTKnSIEC/KJ6atqGJyJEZGgQ7yig3afmihebcE/UXdPSNhQP0BQgSDOEMDQfoA0RqCCDZV5Jus4vp6Yd+vcrPjRDCIIB0amlhdZEO+UZBbLmfrifSLt9ooefZp8XQldhSAVKbaGYvXlUNBAHJSnk4VQwooWAiNodQiA6w8XMgICe/PmN3PNCCFLIwWjLiAzVT0vEDBCVOkxAPrxpMm0uKEpAC9KZM7wuAJhquagRSnYsz+iFWUJAW67hphSCTJ2jJcIKMtHPMi6QFH62EBEC5ZRg7zCdQezqouXCCjzcQS0EyimaFSMAQI5iTLtdjodPAqxnf9EVSneDJ+gDRE6k9H+aEHmV9Isu3a8NtAoLmygvpwXxjxNXBzVtlBdZH0W8iiuuYVnS6l3R+8JZgOY8DAChXyIVVn1sappH5FayzFX1wVag+oBoY725dID73mLhjByRxy4Rj0D2YmgroHcK3ad0/pv1ztKBPtiGx04zeDFEhdUxhAiNjvJGltGhnXyeBCayJAPWlOP7WNiioqVIzostBF/ewPSwQPerLfuzo4PSfoBMnWVhy1fOCO0zEh5XtjqUAo3oB6SpQzv7OregTqi5muEekwO7Tqonn2UsYuErL57x5/Q/kJzHVzbhc++wdKC07IX2BXxpI4uRBCA+V/DYoxBgllUidCzkCmumfxNtTKi+isXfQh9DCx7bicczMtc0/KOBI/cZwTFGkkLVxijL0ULwpathTglLEAp9cDBw5Bf6cJu5KhDPgP/wDsM3wEqPF/glyYQAiBOqr2HtCQFAgsE3f612PDu7JIMOev+b/sN3G8FRdm784vVILoiyH6uGSvV6D30XYMqVaBS4guVC7Zf4skuoLeAJp+Z8Qe8/YgofAKC8eTfnWBT9bcxiMqX9aa3rgEkdh8CVNIq1X+OK0jupid29Wtc/9f6jLIksCnzF5y1r75n9fZwSZC3gP7zNCI6b1X24M8divmI9v6AJORJt/xPvOTzSrA8cI+OnzCqmCwPx8sY9yBajoCluLbb2watq224zSUyHlMc5qqC9AooOiMTQZAxrhuo2vOeI+4yhZGp6yi+9UfrM1pg/JSpKD/73V3j001CR/hGgvMB6+S7AyzF/TTQpEevuAILMOq24QD4ISvXb4qmQ/LyG1v+y2vEEIGo60l+IEJd/T1h8fYIGSTbXhMorIOKV9l0m84I8tBRBIQciCXASgBBgxcAK0H0kOAqIyWcpuaK1iVVI6SgTX74Buzv1/kMsVKBcyuXWopwa5KhG1jIo5SUYlYY6RQJDxNND3N3E7SS+syxvIODyV1oafpqcYUrnPokWbPsNmUizUF7M5Ys/h/JXoZylSC5J79ppMFQ38fTgiTY88qYRTO/4MbRWyGseBGJu8papHoDVA4HWew3vmRQ657jCJr50M1ewGiBz97UJnmjXB1/Bo2+lEragVCyt2YmkwlRMp3MSWJ0MnLjf8PXFbcDLfOkVfPm1SC5N1SYVDHVSGzikD/4HqO54baBUIK16AFlTrVdI70i0obmDrTuMYIznHyi3Tlr+EyjmpW6NFbpfcT6OXUdj/MRZLA2/RbY0ylfSf1sADgbadhj+iF9AqUhafg/KqU3PjkkggSH11O+J1zmNT6Glfie0pPfeJqr3R2hu5fRjeKotNBqKN4pV3wF8TtpGTATRtL6/aYMvAIMg+zLponuglPbbq6jfKEK0/gPItpTL/yzV5eYDe06RiXeEyq8DRHNOJrMv5JpDmJvnvTOAeSHCmBcijHkhwpgXIox5IcKYFyKM/wcAAP//h4bYYlJz5AYAAAAASUVORK5CYII=\n]"); + } + + @Test + void shouldSupportBase64SerializerType() { + Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); + assertThat(serializer.getOutputFormat()).isEqualTo("BASE64"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java new file mode 100644 index 0000000..326f52a --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java @@ -0,0 +1,16 @@ +package au.com.origin.snapshots.serializers; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotSerializerContext; + +public class LowercaseToStringSerializer implements SnapshotSerializer { + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + return gen.toSnapshot(object.toString().toLowerCase()); + } + + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java new file mode 100644 index 0000000..416b813 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java @@ -0,0 +1,89 @@ +package au.com.origin.snapshots.serializers; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotHeader; +import au.com.origin.snapshots.SnapshotSerializerContext; +import lombok.AllArgsConstructor; +import lombok.Data; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ToStringSnapshotSerializerTest { + ToStringSnapshotSerializer serializer = new ToStringSnapshotSerializer(); + + private SnapshotSerializerContext mockSnapshotGenerator = + new SnapshotSerializerContext( + "base64Test", + null, + new SnapshotHeader(), + ToStringSnapshotSerializerTest.class, + null // it's not used in these scenarios + ); + + @Test + void shouldSnapshotAnyString() { + Snapshot result = serializer.apply("John Doe", mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\nJohn Doe\n]"); + } + + @Test + void shouldSnapshotUnicode() { + Snapshot result = serializer.apply("🤔", mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\n🤔\n]"); + } + + @Test + void shouldSnapshotAnyObject() { + Snapshot result = serializer.apply(new Dummy(1, "John Doe"), mockSnapshotGenerator); + assertThat(result.getBody()) + .isEqualTo("[\nToStringSerializerTest.Dummy(id=1, name=John Doe)\n]"); + } + + @Test + void shouldSnapshotMultipleObjects() { + Snapshot result = serializer.apply(new Dummy(1, "John Doe"), mockSnapshotGenerator); + assertThat(result.getBody()) + .isEqualTo("[\nToStringSerializerTest.Dummy(id=1, name=John Doe)\n]"); + } + + @Test + void shouldSupportBase64SerializerType() { + assertThat(serializer.getOutputFormat()).isEqualTo("TEXT"); + } + + @Test + void shouldReplaceThreeConsecutiveNewLines() { + Snapshot result = serializer.apply("John\n\n\nDoe", mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\nJohn\n.\n.\nDoe\n]"); + } + + @Test + void shouldReplaceTwoConsecutiveNewLinesAtEnd() { + Snapshot result = serializer.apply("John Doe\n\n", mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\nJohn Doe\n.\n.\n]"); + } + + @Test + void shouldReplaceTwoConsecutiveNewLinesAtBeginning() { + Snapshot result = serializer.apply("\n\nJohn Doe", mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\n.\n.\nJohn Doe\n]"); + } + + @Test + void shouldReplaceIllegalNewlineSequencesEverywhere() { + Snapshot result = serializer.apply("\n\nJohn\n\n\nDoe\n\n", mockSnapshotGenerator); + assertThat(result.getBody()).isEqualTo("[\n.\n.\nJohn\n.\n.\nDoe\n.\n.\n]"); + } + + @AllArgsConstructor + @Data + private static class Dummy { + private int id; + private String name; + + public String toString() { + return "ToStringSerializerTest.Dummy(id=" + this.getId() + ", name=" + this.getName() + ")"; + } + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java new file mode 100644 index 0000000..b953de7 --- /dev/null +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java @@ -0,0 +1,16 @@ +package au.com.origin.snapshots.serializers; + +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotSerializerContext; + +public class UppercaseToStringSerializer implements SnapshotSerializer { + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + return gen.toSnapshot(object.toString().toUpperCase()); + } + + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } +} diff --git a/java-snapshot-testing-core/src/test/resources/origin-logo.png b/snapshot-testing-core/src/test/resources/origin-logo.png similarity index 100% rename from java-snapshot-testing-core/src/test/resources/origin-logo.png rename to snapshot-testing-core/src/test/resources/origin-logo.png diff --git a/java-snapshot-testing-core/src/test/resources/snapshot.properties b/snapshot-testing-core/src/test/resources/snapshot.properties similarity index 100% rename from java-snapshot-testing-core/src/test/resources/snapshot.properties rename to snapshot-testing-core/src/test/resources/snapshot.properties diff --git a/snapshot-testing-jackson/pom.xml b/snapshot-testing-jackson/pom.xml new file mode 100644 index 0000000..e9d5774 --- /dev/null +++ b/snapshot-testing-jackson/pom.xml @@ -0,0 +1,165 @@ + + + 4.0.0 + + io.github.finoid + snapshot-testing-parent + ${revision} + ../pom.xml + + + snapshot-testing-jackson + finoid-snapshot-testing-jackson + + + + 21 + 21 + 21 + 21 + UTF-8 + + 5.7.2 + 2.20.1 + 3.11.1 + 2.0.0-alpha0 + + + + + org.checkerframework + checker-qual + + + + + com.fasterxml.jackson.core + jackson-core + 2.20.1 + + + com.fasterxml.jackson.core + jackson-databind + 2.20.1 + + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + 2.20.1 + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.20.1 + + + + + org.slf4j + slf4j-api + 2.0.17 + + + + org.slf4j + slf4j-simple + 2.0.17 + test + + + + + io.github.finoid + snapshot-testing-core + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + provided + + + + + org.slf4j + slf4j-simple + ${slf4j.simple.version} + test + + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + + + + + + + + + + + + + + + + + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + + + + + + + + + + + + + + + + + + + + org.skyscreamer + jsonassert + 1.5.1 + test + + + + \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java rename to snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java diff --git a/java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java diff --git a/java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java rename to snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java diff --git a/java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java similarity index 73% rename from java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java index f183fd9..1e32d6b 100644 --- a/java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java @@ -13,10 +13,9 @@ *

Note that collections will be ordered which mar or may not be desirable given your use case. */ public class DeterministicJacksonSnapshotSerializer extends JacksonSnapshotSerializer { - - @Override - public void configure(ObjectMapper objectMapper) { - objectMapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY); - objectMapper.registerModule(new DeterministicCollectionModule()); - } + @Override + public void configure(ObjectMapper objectMapper) { + objectMapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY); + objectMapper.registerModule(new DeterministicCollectionModule()); + } } diff --git a/java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java rename to snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java diff --git a/java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java rename to snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap diff --git a/java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap rename to snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap diff --git a/java-snapshot-testing-plugin-jackson/src/test/resources/snapshot.properties b/snapshot-testing-jackson/src/test/resources/snapshot.properties similarity index 100% rename from java-snapshot-testing-plugin-jackson/src/test/resources/snapshot.properties rename to snapshot-testing-jackson/src/test/resources/snapshot.properties diff --git a/snapshot-testing-jackson3/pom.xml b/snapshot-testing-jackson3/pom.xml new file mode 100644 index 0000000..3a73d3f --- /dev/null +++ b/snapshot-testing-jackson3/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + + io.github.finoid + snapshot-testing-parent + ${revision} + ../pom.xml + + + snapshot-testing-jackson3 + finoid-snapshot-testing-jackson3 + + + + 21 + 21 + 21 + 21 + UTF-8 + + 5.7.2 + 2.20.1 + 3.11.1 + 2.0.0-alpha0 + + + + + org.checkerframework + checker-qual + + + + + tools.jackson.core + jackson-core + 3.0.3 + + + tools.jackson.core + jackson-databind + 3.0.3 + + + + + org.slf4j + slf4j-api + 2.0.17 + + + + org.slf4j + slf4j-simple + 2.0.17 + test + + + + + io.github.finoid + snapshot-testing-core + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + provided + + + + + org.slf4j + slf4j-simple + ${slf4j.simple.version} + test + + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + + + + + + + + + + + + + + + + + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + + + + + + + + + + + + + + + + + + + + org.skyscreamer + jsonassert + 1.5.1 + test + + + + \ No newline at end of file diff --git a/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java rename to snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java diff --git a/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java diff --git a/java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java rename to snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap diff --git a/java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap rename to snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap diff --git a/java-snapshot-testing-plugin-jackson3/src/test/resources/snapshot.properties b/snapshot-testing-jackson3/src/test/resources/snapshot.properties similarity index 100% rename from java-snapshot-testing-plugin-jackson3/src/test/resources/snapshot.properties rename to snapshot-testing-jackson3/src/test/resources/snapshot.properties diff --git a/snapshot-testing-junit5/pom.xml b/snapshot-testing-junit5/pom.xml new file mode 100644 index 0000000..d5bba4f --- /dev/null +++ b/snapshot-testing-junit5/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + io.github.finoid + snapshot-testing-parent + ${revision} + ../pom.xml + + + snapshot-testing-junit5 + finoid-snapshot-testing-junit5 + + + + 21 + 21 + 21 + 21 + UTF-8 + + 5.7.2 + 2.20.1 + 3.11.1 + 2.0.0-alpha0 + + + + + org.checkerframework + checker-qual + + + + org.slf4j + slf4j-api + 2.0.17 + + + + org.slf4j + slf4j-simple + 2.0.17 + test + + + + + io.github.finoid + snapshot-testing-core + + + io.github.finoid + snapshot-testing-jackson + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + provided + + + + + org.slf4j + slf4j-simple + ${slf4j.simple.version} + test + + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + + + + + + + + + + + + + + + + + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + test + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + test + + + + + \ No newline at end of file diff --git a/java-snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java b/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java similarity index 99% rename from java-snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java rename to snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java index ec21f86..17f67be 100644 --- a/java-snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java +++ b/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java @@ -10,6 +10,7 @@ import au.com.origin.snapshots.utils.ReflectionUtils; import java.lang.reflect.Field; import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap similarity index 100% rename from java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap rename to snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap diff --git a/java-snapshot-testing-junit5/src/test/resources/junit-platform.properties b/snapshot-testing-junit5/src/test/resources/junit-platform.properties similarity index 100% rename from java-snapshot-testing-junit5/src/test/resources/junit-platform.properties rename to snapshot-testing-junit5/src/test/resources/junit-platform.properties diff --git a/java-snapshot-testing-junit5/src/test/resources/snapshot.properties b/snapshot-testing-junit5/src/test/resources/snapshot.properties similarity index 100% rename from java-snapshot-testing-junit5/src/test/resources/snapshot.properties rename to snapshot-testing-junit5/src/test/resources/snapshot.properties diff --git a/snapshot-testing-junit6/pom.xml b/snapshot-testing-junit6/pom.xml new file mode 100644 index 0000000..da415ff --- /dev/null +++ b/snapshot-testing-junit6/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + io.github.finoid + snapshot-testing-parent + ${revision} + ../pom.xml + + + snapshot-testing-junit6 + finoid-snapshot-testing-junit6 + + + + 21 + 21 + 21 + 21 + UTF-8 + + 6.0.2 + 2.20.1 + 3.11.1 + 2.0.0-alpha0 + + + + + org.checkerframework + checker-qual + + + + org.slf4j + slf4j-api + 2.0.17 + + + + org.slf4j + slf4j-simple + 2.0.17 + test + + + + + io.github.finoid + snapshot-testing-core + + + io.github.finoid + snapshot-testing-jackson3 + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + provided + + + + + org.slf4j + slf4j-simple + ${slf4j.simple.version} + test + + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + + + + + + + + + + + + + + + + + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + test + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + test + + + + + \ No newline at end of file diff --git a/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java b/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java new file mode 100644 index 0000000..17f67be --- /dev/null +++ b/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java @@ -0,0 +1,128 @@ +package au.com.origin.snapshots.junit5; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.SnapshotVerifier; +import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfig; +import au.com.origin.snapshots.config.SnapshotConfigInjector; +import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import au.com.origin.snapshots.logging.LoggingHelper; +import au.com.origin.snapshots.utils.ReflectionUtils; +import java.lang.reflect.Field; +import lombok.extern.slf4j.Slf4j; + +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; +import org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor; +import org.junit.jupiter.engine.descriptor.ClassTestDescriptor; + +@Slf4j +public class SnapshotExtension + implements AfterAllCallback, + BeforeAllCallback, + SnapshotConfigInjector, + ParameterResolver, + BeforeEachCallback { + + private SnapshotVerifier snapshotVerifier; + + @Override + public void beforeAll(ExtensionContext context) { + // don't fail if a test is run alone from the IDE for example + boolean failOnOrphans = shouldFailOnOrphans(context); + Class testClass = + context + .getTestClass() + .orElseThrow(() -> new SnapshotMatchException("Unable to locate Test class")); + this.snapshotVerifier = new SnapshotVerifier(getSnapshotConfig(), testClass, failOnOrphans); + } + + @Override + public void afterAll(ExtensionContext context) { + this.snapshotVerifier.validateSnapshots(); + } + + @Override + public SnapshotConfig getSnapshotConfig() { + return new PropertyResolvingSnapshotConfig(); + } + + /** + * FIXME This is a hack until I find the correct way to determine if a test run is individual or + * as part of a class + * + * @param context + * @return + */ + private boolean shouldFailOnOrphans(ExtensionContext context) { + try { + Field field = context.getClass().getSuperclass().getDeclaredField("testDescriptor"); + field.setAccessible(true); + Object testDescriptor = field.get(context); + if (testDescriptor instanceof ClassTestDescriptor) { // Junit 5.3.2 + ClassTestDescriptor classTestDescriptor = (ClassTestDescriptor) testDescriptor; + return classTestDescriptor.getChildren().size() > 1; + } else if (testDescriptor instanceof ClassBasedTestDescriptor) { // Junit 5.7.2 + ClassBasedTestDescriptor classTestDescriptor = (ClassBasedTestDescriptor) testDescriptor; + return classTestDescriptor.getChildren().size() > 1; + } + } catch (Exception e) { + log.error( + "FAILED: (Java Snapshot Testing) Unable to get JUnit5 ClassTestDescriptor or ClassBasedTestDescriptor!\n" + + "Ensure you are using Junit5 >= 5.3.2\n" + + "This may be due to JUnit5 changing their private api as we use reflection to access it\n" + + "Log a support ticket https://github.com/origin-energy/java-snapshot-testing/issues and supply your JUnit5 version\n" + + "Setting failOnOrphans=true as this is the safest option." + + "This means that running a test alone (say from the IDE) will fail the snapshot, you need to run the entire class.", + e); + } + return true; + } + + @Override + public boolean supportsParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + boolean supports = parameterContext.getParameter().getType() == Expect.class; + if (supports) { + LoggingHelper.deprecatedV5( + log, + "Injecting 'Expect' via method a argument is no longer recommended. Consider using instance variable injection instead."); + } + return supports; + } + + @Override + public Object resolveParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return new Expect( + snapshotVerifier, + extensionContext + .getTestMethod() + .orElseThrow(() -> new RuntimeException("getTestMethod() is missing"))); + } + + @Override + public void beforeEach(ExtensionContext context) { + if (context.getTestInstance().isPresent() && context.getTestMethod().isPresent()) { + ReflectionUtils.findFieldByPredicate( + context.getTestClass().get(), (field) -> field.getType() == Expect.class) + .ifPresent( + (field) -> { + Expect expect = Expect.of(snapshotVerifier, context.getTestMethod().get()); + ReflectionUtils.makeAccessible(field); + try { + field.set(context.getTestInstance().get(), expect); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + }); + } + } +} diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java new file mode 100644 index 0000000..8b89737 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java @@ -0,0 +1,24 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.junit5.SnapshotExtension; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith({SnapshotExtension.class}) +public class BaseClassTest { + + class TestBase { + Expect expect; + } + + @Nested + @ExtendWith(SnapshotExtension.class) + class NestedClass extends TestBase { + + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } + } +} diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java new file mode 100644 index 0000000..7267329 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java @@ -0,0 +1,52 @@ +package au.com.origin.snapshots; + +import static org.assertj.core.api.Assertions.assertThat; + +import au.com.origin.snapshots.junit5.SnapshotExtension; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith({SnapshotExtension.class}) +public class NestedClassTest { + + @AfterAll + public static void afterAll() { + Path path = + Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest.snap"); + assertThat(Files.exists(path)).isFalse(); + } + + @Nested + class NestedClassWithExpectArgument { + + @Test + public void helloWorldTest(Expect expect) { + expect.toMatchSnapshot("Hello World"); + } + } + + @Nested + class NestedClassWithoutSnapshot { + + @Test + public void helloWorldTest() { + assertThat(true).isTrue(); + } + } + + @Nested + class NestedClassWithExpectInstance { + + Expect expect; + + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } + } +} diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java new file mode 100644 index 0000000..d4ac92c --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java @@ -0,0 +1,35 @@ +package au.com.origin.snapshots; + +import static org.assertj.core.api.Assertions.assertThat; + +import au.com.origin.snapshots.junit5.SnapshotExtension; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +public class NestedClassTestWithExtends { + + @AfterAll + public static void afterAll() { + Path path = + Paths.get( + "src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); + assertThat(Files.exists(path)).isFalse(); + } + + @ExtendWith(SnapshotExtension.class) + @Nested + class NestedClass { + + Expect expect; + + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } + } +} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRunnerUsedTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java similarity index 58% rename from java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRunnerUsedTest.java rename to snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java index d2ec5b0..e1c4044 100644 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/SnapshotRunnerUsedTest.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java @@ -1,12 +1,12 @@ package au.com.origin.snapshots; import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit4.SnapshotRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import au.com.origin.snapshots.junit5.SnapshotExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@RunWith(SnapshotRunner.class) -public class SnapshotRunnerUsedTest { +@ExtendWith(SnapshotExtension.class) +public class SnapshotExtensionUsedTest { private Expect expect; @@ -22,23 +22,23 @@ public void shouldUseExtensionAgain(Expect expect) { @Test public void shouldUseExtensionViaInstanceVariable() { - this.expect.toMatchSnapshot("Hello World"); + expect.toMatchSnapshot("Hello World"); } @Test public void shouldUseExtensionAgainViaInstanceVariable() { - this.expect.toMatchSnapshot("Hello World"); + expect.toMatchSnapshot("Hello World"); } @SnapshotName("hello_world") @Test - public void shouldUseExtensionWithSnapshotName() { + public void snapshotWithName() { expect.toMatchSnapshot("Hello World"); } - @SnapshotName("hello_world_again") + @SnapshotName("hello_world_2") @Test - public void shouldUseExtensionAgainWithSnapshotName(Expect expect) { + public void snapshotWithNameAgain() { expect.toMatchSnapshot("Hello World"); } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java new file mode 100644 index 0000000..1f63e88 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java @@ -0,0 +1,51 @@ +package au.com.origin.snapshots; + +import au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; +import au.com.origin.snapshots.junit5.SnapshotExtension; +import java.util.stream.Stream; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +@ExtendWith({SnapshotExtension.class}) +class SnapshotParameterTest { + + private Expect expect; + + static Stream testData() { + + return Stream.of( + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario3", "test input 2"), + Arguments.of("Scenario3", "test input 2")); + } + + @ParameterizedTest + @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { + expect.toMatchSnapshot("Duplicates are OK"); + expect.toMatchSnapshot("Duplicates are OK"); + expect.scenario("Scenario1").toMatchSnapshot("Additional snapshots need to include a scenario"); + expect + .serializer(JacksonSnapshotSerializer.class) + .scenario(scenario) + .toMatchSnapshot(testInput); + } + + @ParameterizedTest + @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { + this.expect.toMatchSnapshot("Duplicates are OK"); + this.expect.toMatchSnapshot("Duplicates are OK"); + this.expect + .scenario("Scenario1") + .toMatchSnapshot("Additional snapshots need to include a scenario"); + this.expect + .serializer(JacksonSnapshotSerializer.class) + .scenario(scenario) + .toMatchSnapshot(testInput); + } +} diff --git a/java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap similarity index 100% rename from java-snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap rename to snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap new file mode 100644 index 0000000..e70d0b5 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap @@ -0,0 +1,3 @@ +au.com.origin.snapshots.NestedClassTest$NestedClassWithExpectArgument.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap new file mode 100644 index 0000000..b9bf45e --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap @@ -0,0 +1,3 @@ +au.com.origin.snapshots.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap new file mode 100644 index 0000000..09fb8b1 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap @@ -0,0 +1,28 @@ +au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtension=[ +Hello World +] + + +au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ +Hello World +] + + +au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ +Hello World +] + + +au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ +Hello World +] + + +hello_world=[ +Hello World +] + + +hello_world_2=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap new file mode 100644 index 0000000..a632d11 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap @@ -0,0 +1,38 @@ +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest=[ +Duplicates are OK +] + + +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ +Duplicates are OK +] + + +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ + "test input 1" +] + + +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ + "test input 2" +] + + +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ + "test input 1" +] + + +au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ + "test input 2" +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java new file mode 100644 index 0000000..841635c --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java @@ -0,0 +1,32 @@ +package au.com.origin.snapshots.docs; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.SnapshotVerifier; +import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +// Notice we aren't using any framework extensions +public class CustomFrameworkExample { + + private static SnapshotVerifier snapshotVerifier; + + @BeforeAll + static void beforeAll() { + snapshotVerifier = + new SnapshotVerifier(new PropertyResolvingSnapshotConfig(), CustomFrameworkExample.class); + } + + @AfterAll + static void afterAll() { + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldMatchSnapshotOne(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Hello World"); + } +} diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java new file mode 100644 index 0000000..1f0fece --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java @@ -0,0 +1,18 @@ +package au.com.origin.snapshots.docs; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.annotations.UseSnapshotConfig; +import au.com.origin.snapshots.junit5.SnapshotExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith(SnapshotExtension.class) +// apply your custom snapshot configuration to this test class +@UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) +public class CustomSnapshotConfigExample { + + @Test + public void myTest(Expect expect) { + expect.toMatchSnapshot("hello world"); + } +} diff --git a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4Example.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java similarity index 55% rename from java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4Example.java rename to snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java index cd8cf31..1fe4b8a 100644 --- a/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/docs/JUnit4Example.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java @@ -1,28 +1,25 @@ package au.com.origin.snapshots.docs; import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit4.SnapshotRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import au.com.origin.snapshots.junit5.SnapshotExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -// Ensure you RunWith the SnapshotRunner -@RunWith(SnapshotRunner.class) -public class JUnit4Example { +// Ensure you extend your test class with the SnapshotExtension +@ExtendWith({SnapshotExtension.class}) +public class JUnit5Example { // Option 1: inject Expect as an instance variable private Expect expect; - @SnapshotName("my first test") @Test public void myTest1() { // Verify your snapshot expect.toMatchSnapshot("Hello World"); } - @SnapshotName("my second test") - @Test // Option 2: inject Expect into the method signature + @Test public void myTest2(Expect expect) { expect.toMatchSnapshot("Hello World Again"); } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java new file mode 100644 index 0000000..eae0ab2 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java @@ -0,0 +1,34 @@ +package au.com.origin.snapshots.docs; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.annotations.UseSnapshotConfig; +import au.com.origin.snapshots.junit5.SnapshotExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith(SnapshotExtension.class) +@UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) +public class JUnit5ResolutionHierarchyExample { + + private Expect expect; + + @Test + public void aliasMethodTest() { + expect + .serializer("json") // <------ Using snapshot.properties + .toMatchSnapshot(new TestObject()); + } + + @Test + public void customSerializerTest() { + expect + .serializer(UppercaseToStringSerializer.class) // <------ Using custom serializer + .toMatchSnapshot(new TestObject()); + } + + // Read from LowercaseToStringSnapshotConfig defined on the class + @Test + public void lowercaseTest() { + expect.toMatchSnapshot(new TestObject()); + } +} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java similarity index 72% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java rename to snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java index 265d57e..d333eca 100644 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java @@ -1,7 +1,9 @@ -package au.com.origin.snapshots.serializers; +package au.com.origin.snapshots.docs; import au.com.origin.snapshots.Snapshot; import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; public class LowercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java new file mode 100644 index 0000000..aac8eb5 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java @@ -0,0 +1,12 @@ +package au.com.origin.snapshots.docs; + +import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import au.com.origin.snapshots.serializers.SnapshotSerializer; + +public class LowercaseToStringSnapshotConfig extends PropertyResolvingSnapshotConfig { + + @Override + public SnapshotSerializer getSerializer() { + return new LowercaseToStringSerializer(); + } +} diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java new file mode 100644 index 0000000..0c7d617 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java @@ -0,0 +1,30 @@ +package au.com.origin.snapshots.docs; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.annotations.SnapshotName; +import au.com.origin.snapshots.junit5.SnapshotExtension; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith({SnapshotExtension.class}) +public class MyFirstSnapshotTest { + + private Expect expect; + + @SnapshotName("i_can_give_custom_names_to_my_snapshots") + @Test + public void toStringSerializationTest() { + expect.toMatchSnapshot("Hello World"); + } + + @Test + public void jsonSerializationTest() { + Map map = new HashMap<>(); + map.put("name", "John Doe"); + map.put("age", 40); + + expect.serializer("json").toMatchSnapshot(map); + } +} diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java new file mode 100644 index 0000000..bec56a7 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java @@ -0,0 +1,8 @@ +package au.com.origin.snapshots.docs; + +public class TestObject { + @Override + public String toString() { + return "This is a snapshot of the toString() method"; + } +} diff --git a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java similarity index 72% rename from java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java rename to snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java index 70cd338..9760d3a 100644 --- a/java-snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java @@ -1,7 +1,9 @@ -package au.com.origin.snapshots.serializers; +package au.com.origin.snapshots.docs; import au.com.origin.snapshots.Snapshot; import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.serializers.SerializerType; +import au.com.origin.snapshots.serializers.SnapshotSerializer; public class UppercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap new file mode 100644 index 0000000..2438c51 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap @@ -0,0 +1,3 @@ +au.com.origin.snapshots.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap new file mode 100644 index 0000000..ed598d1 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap @@ -0,0 +1 @@ +au.com.origin.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap new file mode 100644 index 0000000..ed598d1 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap @@ -0,0 +1 @@ +au.com.origin.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap new file mode 100644 index 0000000..7273361 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap @@ -0,0 +1,8 @@ +au.com.origin.snapshots.docs.JUnit5Example.myTest1=[ +Hello World +] + + +au.com.origin.snapshots.docs.JUnit5Example.myTest2=[ +Hello World Again +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap new file mode 100644 index 0000000..b48f7c3 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap @@ -0,0 +1,9 @@ +au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ + { } +] + + +au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD + + +au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap new file mode 100644 index 0000000..1987c84 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap @@ -0,0 +1,11 @@ +au.com.origin.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ + { + "age": 40, + "name": "John Doe" + } +] + + +i_can_give_custom_names_to_my_snapshots=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap new file mode 100644 index 0000000..568a7d0 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap @@ -0,0 +1,11 @@ +au.com.origin.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ + { + "age" : 40, + "name" : "John Doe" + } +] + + +i_can_give_custom_names_to_my_snapshots=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/resources/junit-platform.properties b/snapshot-testing-junit6/src/test/resources/junit-platform.properties new file mode 100644 index 0000000..07bf940 --- /dev/null +++ b/snapshot-testing-junit6/src/test/resources/junit-platform.properties @@ -0,0 +1,2 @@ +junit.jupiter.execution.parallel.enabled=true +junit.jupiter.execution.parallel.mode.default=concurrent \ No newline at end of file diff --git a/java-snapshot-testing-junit4/src/test/resources/snapshot.properties b/snapshot-testing-junit6/src/test/resources/snapshot.properties similarity index 75% rename from java-snapshot-testing-junit4/src/test/resources/snapshot.properties rename to snapshot-testing-junit6/src/test/resources/snapshot.properties index 52d673d..96a861e 100644 --- a/java-snapshot-testing-junit4/src/test/resources/snapshot.properties +++ b/snapshot-testing-junit6/src/test/resources/snapshot.properties @@ -1,4 +1,5 @@ serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer +serializer.json=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter snapshot-dir=__snapshots__ From 8ccdd0e0945bed505855c38a91e85eedabbb72f1 Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Fri, 23 Jan 2026 14:20:34 +0100 Subject: [PATCH 6/9] chore: fix and suppresss codequality warnings --- pom.xml | 51 ++- snapshot-testing-core/pom.xml | 6 +- .../java/au/com/origin/snapshots/Expect.java | 51 ++- .../au/com/origin/snapshots/Snapshot.java | 18 +- .../com/origin/snapshots/SnapshotContext.java | 22 +- .../au/com/origin/snapshots/SnapshotFile.java | 22 +- .../com/origin/snapshots/SnapshotHeader.java | 35 +- .../origin/snapshots/SnapshotProperties.java | 6 +- .../snapshots/SnapshotSerializerContext.java | 12 +- .../origin/snapshots/SnapshotVerifier.java | 5 +- .../snapshots/config/SnapshotConfig.java | 12 +- .../exceptions/ReservedWordException.java | 2 +- .../snapshots/logging/LoggingHelper.java | 3 + .../v1/PlainTextSnapshotReporter.java | 1 + .../ToStringSnapshotSerializer.java | 2 +- .../v1/Base64SnapshotSerializer.java | 7 +- .../v1/ToStringSnapshotSerializer.java | 2 +- .../DebugSnapshotLineEndingsTest.java | 2 +- .../snapshots/OnLoadSnapshotFileTest.java | 7 +- .../origin/snapshots/ReflectionUtilities.java | 3 + .../com/origin/snapshots/SnapshotHeaders.java | 1 + .../snapshots/SnapshotIntegrationTest.java | 3 +- .../SnapshotMatcherScenarioTest.java | 1 + .../origin/snapshots/SnapshotMatcherTest.java | 3 +- ...pshotNameAnnotationWithDuplicatesTest.java | 3 +- .../au/com/origin/snapshots/SnapshotTest.java | 3 +- .../com/origin/snapshots/SnapshotUtils.java | 17 +- .../Base64SnapshotSerializerTest.java | 1 + .../DeterministicCollectionModule.java | 76 +++-- ...eterministicJacksonSnapshotSerializer.java | 12 +- .../JacksonSnapshotSerializer.java | 12 +- ...eterministicJacksonSnapshotSerializer.java | 1 + .../v1/JacksonSnapshotSerializer.java | 101 +++--- .../serializers/v1/SnapshotPrettyPrinter.java | 28 +- .../snapshots/jackson/NoNameChangeTest.java | 20 +- .../jackson/ReflectionUtilities.java | 40 +-- .../snapshots/jackson/docs/BaseEntity.java | 11 +- .../jackson/docs/CustomSerializerTest.java | 25 +- .../docs/HibernateSnapshotSerializer.java | 40 +-- .../jackson/docs/JsonAssertReporter.java | 18 +- .../jackson/docs/JsonObjectComparator.java | 18 +- ...ministicJacksonSnapshotSerializerTest.java | 266 ++++++++-------- .../JacksonSnapshotSerializerTest.java | 301 ++++++++++-------- snapshot-testing-jackson3/pom.xml | 82 ++--- .../v1/DeterministicCollectionModule.java | 3 +- ...eterministicJacksonSnapshotSerializer.java | 1 + .../v1/JacksonSnapshotSerializer.java | 9 +- .../snapshots/jackson3/NoNameChangeTest.java | 20 +- .../jackson3/ReflectionUtilities.java | 40 +-- .../snapshots/jackson3/docs/BaseEntity.java | 11 +- .../jackson3/docs/CustomSerializerTest.java | 25 +- .../jackson3/docs/JsonAssertReporter.java | 18 +- .../jackson3/docs/JsonObjectComparator.java | 18 +- ...ministicJacksonSnapshotSerializerTest.java | 266 ++++++++-------- .../v1/JacksonSnapshotSerializerTest.java | 301 ++++++++++-------- snapshot-testing-junit5/pom.xml | 56 ++-- .../snapshots/junit5/SnapshotExtension.java | 183 ++++++----- .../com/origin/snapshots/BaseClassTest.java | 20 +- .../com/origin/snapshots/NestedClassTest.java | 62 ++-- .../snapshots/NestedClassTestWithExtends.java | 42 +-- .../snapshots/SnapshotExtensionUsedTest.java | 66 ++-- .../snapshots/SnapshotParameterTest.java | 77 ++--- ...assTest$NestedClassWithExpectArgument.snap | 3 - .../docs/CustomFrameworkExample.java | 30 +- .../docs/CustomSnapshotConfigExample.java | 8 +- .../origin/snapshots/docs/JUnit5Example.java | 24 +- .../JUnit5ResolutionHierarchyExample.java | 36 +-- .../docs/LowercaseToStringSerializer.java | 16 +- .../docs/LowercaseToStringSnapshotConfig.java | 8 +- .../snapshots/docs/MyFirstSnapshotTest.java | 31 +- .../com/origin/snapshots/docs/TestObject.java | 8 +- .../docs/UppercaseToStringSerializer.java | 16 +- snapshot-testing-junit6/pom.xml | 56 ++-- .../snapshots/junit5/SnapshotExtension.java | 183 ++++++----- .../com/origin/snapshots/BaseClassTest.java | 20 +- .../com/origin/snapshots/NestedClassTest.java | 62 ++-- .../snapshots/NestedClassTestWithExtends.java | 42 +-- .../snapshots/SnapshotExtensionUsedTest.java | 66 ++-- .../snapshots/SnapshotParameterTest.java | 77 ++--- .../docs/CustomFrameworkExample.java | 30 +- .../docs/CustomSnapshotConfigExample.java | 8 +- .../origin/snapshots/docs/JUnit5Example.java | 24 +- .../JUnit5ResolutionHierarchyExample.java | 36 +-- .../docs/LowercaseToStringSerializer.java | 16 +- .../docs/LowercaseToStringSnapshotConfig.java | 8 +- .../snapshots/docs/MyFirstSnapshotTest.java | 31 +- .../com/origin/snapshots/docs/TestObject.java | 8 +- .../docs/UppercaseToStringSerializer.java | 16 +- 88 files changed, 1787 insertions(+), 1646 deletions(-) delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap diff --git a/pom.xml b/pom.xml index 6f00cd7..9553c5a 100644 --- a/pom.xml +++ b/pom.xml @@ -38,9 +38,8 @@ - false - - + 0.12.8 + true @@ -180,6 +179,52 @@ + + io.github.finoid + codequality-maven-plugin + ${codequality-maven-plugin.version} + + true + + + maven-code-quality + verify + + code-quality + + + + + + ${code-quality.feature.enabled} + DEBUG + DIFF_COVERAGE + + ${code-quality.feature.checkstyle} + ${code-quality.feature.checkstyle.permissive} + + ${code-quality.configuration.checkstyle.suppression-location} + + + + ${code-quality.configuration.checkstyle.suppression-location} + + + + + ${code-quality.feature.error-prone} + ${code-quality.feature.error-prone.permissive} + ${code-quality.feature.null-away} + + + ${code-quality.feature.checker-framework} + ${code-quality.feature.checker-framework.permissive} + + + + + + org.apache.maven.plugins maven-enforcer-plugin diff --git a/snapshot-testing-core/pom.xml b/snapshot-testing-core/pom.xml index 421efac..fe6dbfe 100644 --- a/snapshot-testing-core/pom.xml +++ b/snapshot-testing-core/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -66,7 +66,7 @@ org.opentest4j opentest4j - 1.2.0 + 1.3.0 diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java index b0d6ab9..ec6c980 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java @@ -16,20 +16,18 @@ public class Expect { private final SnapshotVerifier snapshotVerifier; private final Method testMethod; - + private final Map headers = new HashMap<>(); private SnapshotSerializer snapshotSerializer; private SnapshotComparator snapshotComparator; private List snapshotReporters; private String scenario; - private final Map headers = new HashMap<>(); - public static Expect of(SnapshotVerifier snapshotVerifier, Method method) { return new Expect(snapshotVerifier, method); } /** - * Make an assertion on the given input parameters against what already exists + * Make an assertion on the given input parameters against what already exists. * *

If you were previously using varargs and see an error - you can fix the error using * "toMatchSnapshotLegacy", however, a better approach is to use the ".scenario()" feature as @@ -51,7 +49,7 @@ public void toMatchSnapshot(Object object) { if (scenario != null) { snapshotContext.setScenario(scenario); } - snapshotContext.header.putAll(headers); + snapshotContext.getHeader().putAll(headers); snapshotContext.checkValidContext(); @@ -73,7 +71,7 @@ public Expect scenario(String scenario) { } /** - * Apply a custom serializer for this snapshot + * Apply a custom serializer for this snapshot. * * @param serializer your custom serializer * @return Snapshot @@ -84,7 +82,7 @@ public Expect serializer(SnapshotSerializer serializer) { } /** - * Apply a custom serializer for this snapshot + * Apply a custom serializer for this snapshot. * * @param name - the {name} attribute serializer.{name} from snapshot.properties * @return Snapshot @@ -95,7 +93,22 @@ public Expect serializer(String name) { } /** - * Apply a custom comparator for this snapshot + * Apply a custom serializer for this snapshot. + * + * @param serializer your custom serializer + * @return this + * @see au.com.origin.snapshots.serializers.SnapshotSerializer + * @see au.com.origin.snapshots.serializers.ToStringSnapshotSerializer + * @see au.com.origin.snapshots.serializers.Base64SnapshotSerializer + */ + @SneakyThrows + public Expect serializer(Class serializer) { + this.snapshotSerializer = serializer.getConstructor().newInstance(); + return this; + } + + /** + * Apply a custom comparator for this snapshot. * * @param comparator your custom comparator * @return Snapshot @@ -106,7 +119,7 @@ public Expect comparator(SnapshotComparator comparator) { } /** - * Apply a custom comparator for this snapshot + * Apply a custom comparator for this snapshot. * * @param name the {name} attribute comparator.{name} from snapshot.properties * @return Snapshot @@ -118,7 +131,7 @@ public Expect comparator(String name) { /** * Apply a list of custom reporters for this snapshot This will replace the default reporters - * defined in the config + * defined in the config. * * @param reporters your custom reporters * @return Snapshot @@ -130,7 +143,7 @@ public Expect reporters(SnapshotReporter... reporters) { /** * Apply a list of custom reporters for this snapshot This will replace the default reporters - * defined in the config + * defined in the config. * * @param name the {name} attribute reporters.{name} from snapshot.properties * @return Snapshot @@ -140,22 +153,6 @@ public Expect reporters(String name) { return this; } - /** - * Apply a custom serializer for this snapshot. - * - * @param serializer your custom serializer - * @return this - * @see au.com.origin.snapshots.serializers.SnapshotSerializer - *

Example implementations - * @see au.com.origin.snapshots.serializers.ToStringSnapshotSerializer - * @see au.com.origin.snapshots.serializers.Base64SnapshotSerializer - */ - @SneakyThrows - public Expect serializer(Class serializer) { - this.snapshotSerializer = serializer.getConstructor().newInstance(); - return this; - } - /** * Add anything you like to the snapshot header. * diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java index dccc4a0..9db0d0c 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java @@ -20,15 +20,6 @@ public class Snapshot implements Comparable { private final SnapshotHeader header; private final String body; - @Override - public int compareTo(Snapshot other) { - return (name + scenario).compareTo(other.name + other.scenario); - } - - public String getIdentifier() { - return scenario == null ? name : String.format("%s[%s]", name, scenario); - } - public static Snapshot parse(String rawText) { String regex = "^(?.*?)(\\[(?[^]]*)])?=(?

\\{[^}]*?})?(?(.*)$)"; @@ -64,6 +55,15 @@ public static Snapshot parse(String rawText) { .build(); } + @Override + public int compareTo(Snapshot other) { + return (name + scenario).compareTo(other.name + other.scenario); + } + + public String getIdentifier() { + return scenario == null ? name : String.format("%s[%s]", name, scenario); + } + /** * The raw string representation of the snapshot as it would appear in the *.snap file. * diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java index 41540f2..eb66022 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java @@ -27,16 +27,19 @@ public class SnapshotContext { private final SnapshotConfig snapshotConfig; private final SnapshotFile snapshotFile; + private final boolean isCI; @Getter - final Class testClass; - + private final Class testClass; @Getter - final Method testMethod; - - final Object current; - private final boolean isCI; + private final Method testMethod; + private final Object current; + @Setter + @Getter + private String scenario; + @Getter + private SnapshotHeader header = new SnapshotHeader(); @Setter private SnapshotSerializer snapshotSerializer; @Setter @@ -44,13 +47,6 @@ public class SnapshotContext { @Setter private List snapshotReporters; - @Setter - @Getter - String scenario; - - @Getter - SnapshotHeader header = new SnapshotHeader(); - SnapshotContext( SnapshotConfig snapshotConfig, SnapshotFile snapshotFile, diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java index e0e1835..7a055e2 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java @@ -24,6 +24,7 @@ import java.util.stream.Stream; @Slf4j +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class SnapshotFile { public static final String SPLIT_STRING = "\n\n\n"; @@ -45,10 +46,10 @@ public SnapshotFile(String srcDirPath, String fileName, Class testClass) thro new BufferedReader( new InputStreamReader(new FileInputStream(this.fileName), StandardCharsets.UTF_8))) { - String sCurrentLine; + String currentLine; - while ((sCurrentLine = br.readLine()) != null) { - fileContent.append(sCurrentLine + "\n"); + while ((currentLine = br.readLine()) != null) { + fileContent.append(currentLine + "\n"); } String fileText = fileContent.toString(); @@ -81,10 +82,10 @@ public File createDebugFile(Snapshot snapshot) { try (FileOutputStream fileStream = new FileOutputStream(file, false)) { fileStream.write(snapshot.raw().getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to create debug file ", e); } } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to create debug file ", e); } return file; @@ -101,8 +102,8 @@ public void delete() { } @SneakyThrows - public synchronized File createFileIfNotExists(String filename) { - Path path = Paths.get(filename); + public synchronized File createFileIfNotExists(String fileName) { + Path path = Paths.get(fileName); if (!Files.exists(path)) { Files.createDirectories(path.getParent()); Files.createFile(path); @@ -110,10 +111,11 @@ public synchronized File createFileIfNotExists(String filename) { return path.toFile(); } + @SuppressWarnings("SynchronizeOnNonFinalField") // TODO (nw) rewrite public void pushSnapshot(Snapshot snapshot) { synchronized (snapshots) { snapshots.add(snapshot); - TreeSet rawSnapshots = + Set rawSnapshots = snapshots.stream().map(Snapshot::raw).collect(Collectors.toCollection(TreeSet::new)); updateFile(this.fileName, rawSnapshots); } @@ -121,7 +123,7 @@ public void pushSnapshot(Snapshot snapshot) { public synchronized void pushDebugSnapshot(Snapshot snapshot) { debugSnapshots.add(snapshot); - TreeSet rawDebugSnapshots = + Set rawDebugSnapshots = debugSnapshots.stream().map(Snapshot::raw).collect(Collectors.toCollection(TreeSet::new)); updateFile(getDebugFilename(), rawDebugSnapshots); } @@ -132,7 +134,7 @@ private void updateFile(String fileName, Set rawSnapshots) { byte[] myBytes = String.join(SPLIT_STRING, rawSnapshots).getBytes(StandardCharsets.UTF_8); fileStream.write(myBytes); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to write debug file ", e); } } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java index fa2a290..3bd7739 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java @@ -9,8 +9,26 @@ import java.util.regex.Pattern; @RequiredArgsConstructor +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class SnapshotHeader extends HashMap { + @SneakyThrows + public static SnapshotHeader fromJson(String json) { + SnapshotHeader snapshotHeader = new SnapshotHeader(); + + if (json == null) { + return snapshotHeader; + } + + String regex = "\\\"(?.*)\\\": \\\"(?.*)\\\""; + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(json); + while (m.find()) { + snapshotHeader.put(m.group("key"), m.group("value")); + } + return snapshotHeader; + } + // // Manual JSON serialization/deserialization as I don't want to // include another dependency for it @@ -29,21 +47,4 @@ public String toJson() { b.append("}"); return b.toString(); } - - @SneakyThrows - public static SnapshotHeader fromJson(String json) { - SnapshotHeader snapshotHeader = new SnapshotHeader(); - - if (json == null) { - return snapshotHeader; - } - - String regex = "\\\"(?.*)\\\": \\\"(?.*)\\\""; - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(json); - while (m.find()) { - snapshotHeader.put(m.group("key"), m.group("value")); - } - return snapshotHeader; - } } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java index d854792..044e336 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java @@ -10,6 +10,7 @@ import java.util.stream.Collectors; @Slf4j +@SuppressWarnings({"checkstyle:all", "ImmutableEnumChecker"}) // TODO (nw) rewrite public enum SnapshotProperties { INSTANCE; @@ -34,6 +35,7 @@ public static String getOrThrow(String key) { return value.toString(); } + @SuppressWarnings("TypeParameterUnusedInFormals") // TODO (nw) rewrite public static T getInstance(String key) { String value = SnapshotProperties.getOrThrow(key); return createInstance(value); @@ -47,11 +49,11 @@ public static List getInstances(String key) { .collect(Collectors.toList()); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) // TODO (nw) rewrite private static T createInstance(String className) { try { Class clazz = Class.forName(className); - return (T) clazz.newInstance(); + return (T) clazz.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to instantiate class " + className, e); } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java index 39d41a1..1292866 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java @@ -16,19 +16,15 @@ public class SnapshotSerializerContext { @Getter @Setter - private String name; - + private final String name; @Getter @Setter - private String scenario; - + private final String scenario; @Getter @Setter - private SnapshotHeader header; - + private final SnapshotHeader header; @Getter - private Class testClass; - + private final Class testClass; @Getter private final Method testMethod; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java index 588e0ca..a6030f7 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java @@ -39,13 +39,14 @@ public SnapshotVerifier(SnapshotConfig frameworkSnapshotConfig, Class testCla } /** - * Instantiate before any tests have run for a given class + * Instantiate before any tests have run for a given class. * * @param frameworkSnapshotConfig configuration to use * @param failOnOrphans should the test break if snapshots exist with no matching method in the * test class * @param testClass reference to class under test */ + @SneakyThrows public SnapshotVerifier( SnapshotConfig frameworkSnapshotConfig, Class testClass, boolean failOnOrphans) { try { @@ -53,7 +54,7 @@ public SnapshotVerifier( UseSnapshotConfig customConfig = testClass.getAnnotation(UseSnapshotConfig.class); SnapshotConfig snapshotConfig = - customConfig == null ? frameworkSnapshotConfig : customConfig.value().newInstance(); + customConfig == null ? frameworkSnapshotConfig : customConfig.value().getDeclaredConstructor().newInstance(); // Matcher.quoteReplacement required for Windows String testFilename = diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java index 309b9b2..6af4c12 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java @@ -8,7 +8,7 @@ import java.util.Optional; /** - * Snapshot Configuration ---------------------- + * Snapshot Configuration. * *

Implement this interface when integrating `java-snapshot-testing` with a custom testing * library @@ -19,7 +19,7 @@ public interface SnapshotConfig { /** * The base directory where files get written (excluding package directories) default: - * "src/test/java" + * "src/test/java". * *

You might want to override if you have tests under "src/test/integration" for example * @@ -28,14 +28,14 @@ public interface SnapshotConfig { String getOutputDir(); /** - * Subdirectory to store snapshots in + * Subdirectory to store snapshots in. * * @return name of subdirectory */ String getSnapshotDir(); /** - * Optional + * Optional. * * @return snapshots should be updated automatically without verification */ @@ -44,14 +44,14 @@ default Optional updateSnapshot() { } /** - * Optional Override to supply your own custom serialization function + * Optional Override to supply your own custom serialization function. * * @return custom serialization function */ SnapshotSerializer getSerializer(); /** - * Optional Override to supply your own custom comparator function + * Optional Override to supply your own custom comparator function. * * @return custom comparator function */ diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java index 6203059..6579c05 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java @@ -12,7 +12,7 @@ public ReservedWordException(String message) { public ReservedWordException(String element, String reservedWord, List reservedWords) { super( String.format( - "You cannot use the '%s' character inside '%s'. Reserved characters are ", + "You cannot use the '%s' character inside '%s'. Reserved characters are %s", reservedWord, element, reservedWords.stream().collect(Collectors.joining(",")))); } } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java index c7e927e..240181b 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java @@ -1,7 +1,10 @@ package au.com.origin.snapshots.logging; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.slf4j.Logger; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class LoggingHelper { public static void deprecatedV5(Logger log, String message) { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java index 1a4c1c0..209e11b 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java @@ -11,6 +11,7 @@ public class PlainTextSnapshotReporter implements SnapshotReporter { + @SuppressWarnings("UnnecessaryLambda") // TODO (nw) rewrite private static final Supplier NO_DIFF_EXCEPTION_SUPPLIER = () -> new IllegalStateException( diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java index 54ac1bc..e7c5153 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; /** - * This Serializer does a snapshot of the {@link Object#toString()} method + * This Serializer does a snapshot of the {@link Object#toString()} method. * *

Will render each toString() on a separate line */ diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java index db63063..7ed91ad 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java @@ -13,20 +13,19 @@ * will be converted using `.getBytes(StandardCharsets.UTF_8)` method */ public class Base64SnapshotSerializer implements SnapshotSerializer { - private static final ToStringSnapshotSerializer toStringSnapshotSerializer = - new ToStringSnapshotSerializer(); + private static final ToStringSnapshotSerializer TO_STRING_SNAPSHOT_SERIALIZER = new ToStringSnapshotSerializer(); @Override public Snapshot apply(Object object, SnapshotSerializerContext gen) { if (object == null) { - toStringSnapshotSerializer.apply("", gen); + TO_STRING_SNAPSHOT_SERIALIZER.apply("", gen); } byte[] bytes = object instanceof byte[] ? (byte[]) object : object.toString().getBytes(StandardCharsets.UTF_8); String encoded = Base64.getEncoder().encodeToString(bytes); - return toStringSnapshotSerializer.apply(encoded, gen); + return TO_STRING_SNAPSHOT_SERIALIZER.apply(encoded, gen); } @Override diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java index f43faf9..6d5bbf0 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java @@ -8,7 +8,7 @@ import lombok.extern.slf4j.Slf4j; /** - * This Serializer does a snapshot of the {@link Object#toString()} method + * This Serializer does a snapshot of the {@link Object#toString()} method. * *

Will render each toString() on a separate line */ diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java index 7741130..1fa8889 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java @@ -48,7 +48,7 @@ void beforeEach() { * Scenario: - An existing snapshot file checked out from git will have CR LF line endings on * Windows OS - A newly created snapshot file will have LF line endings on any OS (see * MultiLineSnapshotSerializer) Expectation: - As snapshot file content is identical (except for - * line endings), the debug file should not be created + * line endings), the debug file should not be created. */ @DisplayName( "Debug file should not be created when snapshots match the existing snapshot regardless of line endings") diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java index 5581c44..6380c01 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java @@ -22,7 +22,8 @@ public class OnLoadSnapshotFileTest { private static final String SNAPSHOT_FILE_PATH = "src/test/java/au/com/origin/snapshots/__snapshots__/OnLoadSnapshotFileTest.snap"; - private final SnapshotConfig CUSTOM_SNAPSHOT_CONFIG = new BaseSnapshotConfig(); + + private static final SnapshotConfig CUSTOM_SNAPSHOT_CONFIG = new BaseSnapshotConfig(); @BeforeAll static void beforeAll() throws IOException { @@ -42,10 +43,10 @@ private static void createSnapshotFile(String snapshot) { try (FileOutputStream fileStream = new FileOutputStream(file, false)) { fileStream.write(snapshot.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to write debug file ", e); } } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException("Unable to write debug file ", e); } } diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java index 9cb126d..ca86c6c 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java @@ -1,11 +1,14 @@ package au.com.origin.snapshots; import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import java.lang.reflect.Method; import java.util.Optional; import java.util.stream.Stream; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class ReflectionUtilities { // FIXME consider guava reflection instead diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java index c5cec1f..2f98ba0 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite @ExtendWith(MockitoExtension.class) public class SnapshotHeaders { diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java index bc48e50..2abe87f 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java @@ -13,11 +13,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite @ExtendWith(MockitoExtension.class) public class SnapshotIntegrationTest { - private static final SnapshotConfig DEFAULT_CONFIG = new BaseSnapshotConfig(); - static SnapshotVerifier snapshotVerifier; @BeforeAll diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java index a74f93a..619cd3e 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java @@ -15,6 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite @ExtendWith(MockitoExtension.class) class SnapshotMatcherScenarioTest { diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java index 7871004..9cf5515 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java @@ -15,12 +15,11 @@ import static org.assertj.core.api.Assertions.assertThat; +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite @ExtendWith(MockitoExtension.class) class SnapshotMatcherTest { - private static final String FILE_PATH = "src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotMatcherTest.snap"; - static SnapshotVerifier snapshotVerifier; @BeforeAll diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java index a7e2923..1d70324 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java @@ -16,7 +16,8 @@ void canUseSnapshotNameAnnotation(TestInfo testInfo) { assertThrows( SnapshotExtensionException.class, () -> new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()), - "Oops, looks like you set the same name of two separate snapshots @SnapshotName(\"hello_world\") in class au.com.origin.snapshots.SnapshotNameAnnotationTest"); + "Oops, looks like you set the same name of two separate snapshots @SnapshotName(\"hello_world\") in " + + "class au.com.origin.snapshots.SnapshotNameAnnotationTest"); } @SnapshotName("hello_world") diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java index 8d14d31..092948a 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java @@ -76,8 +76,7 @@ public void shouldParseSnapshotWithScenarioAndHeaders() { } @Test - public void - shouldParseSnapshotWithScenarioAndBodyWithSomethingSimilarToAnScenarioToConfuseRegex() { + public void shouldParseSnapshotWithScenarioAndBodyWithSomethingSimilarToAnScenarioToConfuseRegex() { Snapshot snapshot = Snapshot.parse( Snapshot.builder() diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java index 47b77fd..d471685 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java @@ -1,6 +1,8 @@ package au.com.origin.snapshots; import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.apache.commons.io.FileUtils; import org.mockito.ArgumentCaptor; @@ -11,13 +13,15 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.verify; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class SnapshotUtils { - public static HashMap>> extractArgs( + public static Map>> extractArgs( T object, String methodName, SnapshotCaptor... snapshotCaptors) { List captors = new ArrayList<>(); Class[] classes = new Class[snapshotCaptors.length]; @@ -32,7 +36,7 @@ public static HashMap>> extractAr return process(object, methodName, captors, classes, snapshotCaptors); } - public static HashMap>> extractArgs( + public static Map>> extractArgs( T object, String methodName, Class... classes) { List captors = new ArrayList<>(); @@ -43,13 +47,13 @@ public static HashMap>> extractAr return process(object, methodName, captors, classes, null); } - private static HashMap>> process( + private static Map>> process( T object, String methodName, List captors, Class[] classes, SnapshotCaptor[] snapshotCaptors) { - HashMap>> result = new HashMap<>(); + Map>> result = new HashMap<>(); try { Parameter[] parameters = object.getClass().getDeclaredMethod(methodName, classes).getParameters(); @@ -61,7 +65,7 @@ private static HashMap>> process( verify(object, atLeastOnce()), captors.stream().map(ArgumentCaptor::capture).toArray()); - List> extractedObjects = new ArrayList<>(); + List> extractedObjects = new ArrayList<>(); int numberOfCall; @@ -69,7 +73,7 @@ private static HashMap>> process( numberOfCall = captors.get(0).getAllValues().size(); for (int i = 0; i < numberOfCall; i++) { - LinkedHashMap objectMap = new LinkedHashMap<>(); + Map objectMap = new LinkedHashMap<>(); int j = 0; for (ArgumentCaptor captor : captors) { @@ -99,7 +103,6 @@ public static void copyTestSnapshots() { Paths.get("src/test/java/au/com/origin/snapshots/existing-snapshots").toFile(), Paths.get("src/test/java/au/com/origin/snapshots").toFile()); } catch (IOException e) { - e.printStackTrace(); throw new RuntimeException("Can't move files to __snapshots__ folder"); } } diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java index 57e4d5c..27c2f68 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java +++ b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java @@ -36,6 +36,7 @@ void shouldSnapshotAnyString() { } @Test + @SuppressWarnings("checkstyle:LineLength") void shouldSnapshotAFile() throws Exception { Base64SnapshotSerializer serializer = new Base64SnapshotSerializer(); File f = new File("src/test/resources/origin-logo.png"); diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java index f4f966c..c4c4c8a 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java +++ b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java @@ -4,55 +4,53 @@ import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.module.SimpleModule; +import lombok.extern.slf4j.Slf4j; + import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.Objects; import java.util.stream.Collectors; -import lombok.extern.slf4j.Slf4j; -/** - * Inspired by: - * https://www.stubbornjava.com/posts/creating-a-somewhat-deterministic-jackson-objectmapper - */ @Slf4j +@SuppressWarnings({"checkstyle:all", "this-escape"}) // TODO (nw) rewrite public class DeterministicCollectionModule extends SimpleModule { - public DeterministicCollectionModule() { - addSerializer(Collection.class, new CollectionSerializer()); - } - - /** - * Collections gets converted into a sorted Object[]. This then gets serialized using the default - * Array serializer. - */ - private static class CollectionSerializer extends JsonSerializer { - - @Override - public void serialize(Collection value, JsonGenerator gen, SerializerProvider serializers) - throws IOException { - Object[] sorted = convert(value); - serializers.defaultSerializeValue(sorted, gen); + public DeterministicCollectionModule() { + addSerializer(Collection.class, new CollectionSerializer()); } - private Object[] convert(Collection value) { - if (value == null || value.isEmpty()) { - return Collections.emptyList().toArray(); - } - - try { - return value.stream() - .filter(Objects::nonNull) - .sorted() - .collect(Collectors.toList()) - .toArray(); - } catch (ClassCastException ex) { - log.warn( - "Unable to sort() collection - this may result in a non deterministic snapshot.\n" - + "Consider adding a custom serializer for this type via the JacksonSnapshotSerializer#configure() method.\n" - + ex.getMessage()); - return value.toArray(); - } + /** + * Collections gets converted into a sorted Object[]. This then gets serialized using the default + * Array serializer. + */ + private static class CollectionSerializer extends JsonSerializer { + + @Override + public void serialize(Collection value, JsonGenerator gen, SerializerProvider serializers) + throws IOException { + Object[] sorted = convert(value); + serializers.defaultSerializeValue(sorted, gen); + } + + private Object[] convert(Collection value) { + if (value == null || value.isEmpty()) { + return Collections.emptyList().toArray(); + } + + try { + return value.stream() + .filter(Objects::nonNull) + .sorted() + .collect(Collectors.toList()) + .toArray(); + } catch (ClassCastException ex) { + log.warn( + "Unable to sort() collection - this may result in a non deterministic snapshot.\n" + + "Consider adding a custom serializer for this type via the JacksonSnapshotSerializer#configure() method.\n" + + ex.getMessage()); + return value.toArray(); + } + } } - } } diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java index d4feea2..36b6e27 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java @@ -15,10 +15,10 @@ @Slf4j public class DeterministicJacksonSnapshotSerializer extends au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer { - public DeterministicJacksonSnapshotSerializer() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer` in `snapshot.properties`"); - } + public DeterministicJacksonSnapshotSerializer() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer` in `snapshot.properties`"); + } } diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java index 74f1fed..52cd065 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java @@ -8,10 +8,10 @@ public class JacksonSnapshotSerializer extends au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer { - public JacksonSnapshotSerializer() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer` in `snapshot.properties`"); - } + public JacksonSnapshotSerializer() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer` in `snapshot.properties`"); + } } diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java index 1e32d6b..b632ca3 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java @@ -12,6 +12,7 @@ * *

Note that collections will be ordered which mar or may not be desirable given your use case. */ +@SuppressWarnings("deprecation") // TODO (nw) rewrite public class DeterministicJacksonSnapshotSerializer extends JacksonSnapshotSerializer { @Override public void configure(ObjectMapper objectMapper) { diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java index 4897482..5c4b9b8 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java @@ -10,64 +10,67 @@ import com.fasterxml.jackson.core.PrettyPrinter; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import java.util.Arrays; + +import java.util.Collections; import java.util.List; +@SuppressWarnings({"checkstyle:all", "deprecation"}) // TODO (nw) rewrite public class JacksonSnapshotSerializer implements SnapshotSerializer { - private final PrettyPrinter pp = new SnapshotPrettyPrinter(); - private final ObjectMapper objectMapper = - new ObjectMapper() { - { - this.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - this.enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID); - this.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - this.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); - this.setSerializationInclusion(JsonInclude.Include.NON_NULL); + private final PrettyPrinter pp = new SnapshotPrettyPrinter(); + private final ObjectMapper objectMapper = + new ObjectMapper() { + { + this.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); + this.enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID); + this.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + this.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); + this.setSerializationInclusion(JsonInclude.Include.NON_NULL); - if (shouldFindAndRegisterModules()) { - this.findAndRegisterModules(); - } + if (shouldFindAndRegisterModules()) { + this.findAndRegisterModules(); + } - this.setVisibility( - this.getSerializationConfig() - .getDefaultVisibilityChecker() - .withFieldVisibility(JsonAutoDetect.Visibility.ANY) - .withGetterVisibility(JsonAutoDetect.Visibility.NONE) - .withSetterVisibility(JsonAutoDetect.Visibility.NONE) - .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); - JacksonSnapshotSerializer.this.configure(this); - } - }; + this.setVisibility( + this.getSerializationConfig() + .getDefaultVisibilityChecker() + .withFieldVisibility(JsonAutoDetect.Visibility.ANY) + .withGetterVisibility(JsonAutoDetect.Visibility.NONE) + .withSetterVisibility(JsonAutoDetect.Visibility.NONE) + .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); + JacksonSnapshotSerializer.this.configure(this); + } + }; - /** - * Override to customize the Jackson objectMapper - * - * @param objectMapper existing ObjectMapper - */ - public void configure(ObjectMapper objectMapper) {} + /** + * Override to customize the Jackson objectMapper + * + * @param objectMapper existing ObjectMapper + */ + public void configure(ObjectMapper objectMapper) { + } - /** - * Override to control the registration of all available jackson modules within the classpath - * which are locatable via JDK ServiceLoader facility, along with module-provided SPI. - */ - protected boolean shouldFindAndRegisterModules() { - return true; - } + /** + * Override to control the registration of all available jackson modules within the classpath + * which are locatable via JDK ServiceLoader facility, along with module-provided SPI. + */ + protected boolean shouldFindAndRegisterModules() { + return true; + } - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - try { - List objects = Arrays.asList(object); - String body = objectMapper.writer(pp).writeValueAsString(objects); - return gen.toSnapshot(body); - } catch (Exception e) { - throw new SnapshotExtensionException("Jackson Serialization failed", e); + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + try { + List objects = Collections.singletonList(object); + String body = objectMapper.writer(pp).writeValueAsString(objects); + return gen.toSnapshot(body); + } catch (Exception e) { + throw new SnapshotExtensionException("Jackson Serialization failed", e); + } } - } - @Override - public String getOutputFormat() { - return SerializerType.JSON.name(); - } + @Override + public String getOutputFormat() { + return SerializerType.JSON.name(); + } } diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java index 479ea9c..a11db6f 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java +++ b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java @@ -5,19 +5,21 @@ class SnapshotPrettyPrinter extends DefaultPrettyPrinter { - public SnapshotPrettyPrinter() { - super(""); - Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n"); - this.indentArraysWith(lfOnlyIndenter); - this.indentObjectsWith(lfOnlyIndenter); + @SuppressWarnings("deprecation") // TODO (nw) rewrite + public SnapshotPrettyPrinter() { + super(""); + Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n"); + this.indentArraysWith(lfOnlyIndenter); + this.indentObjectsWith(lfOnlyIndenter); - this._objectFieldValueSeparatorWithSpaces = - this._separators.getObjectFieldValueSeparator() + " "; - } + this._objectFieldValueSeparatorWithSpaces = + this._separators.getObjectFieldValueSeparator() + " "; + } - // It's a requirement - // @see https://github.com/FasterXML/jackson-databind/issues/2203 - public DefaultPrettyPrinter createInstance() { - return new DefaultPrettyPrinter(this); - } + // It's a requirement + // @see https://github.com/FasterXML/jackson-databind/issues/2203 + @Override + public DefaultPrettyPrinter createInstance() { + return new DefaultPrettyPrinter(this); + } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java index 61764b7..b66c03c 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java @@ -1,11 +1,11 @@ package au.com.origin.snapshots.jackson; -import static org.assertj.core.api.Assertions.assertThat; - import au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; import au.com.origin.snapshots.jackson.serializers.JacksonSnapshotSerializer; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + /** * These classes are likely defined in snapshot.properties as a string. * @@ -13,12 +13,12 @@ */ public class NoNameChangeTest { - @Test - public void serializersApiShouldNotChange() { - assertThat(JacksonSnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.jackson.serializers.JacksonSnapshotSerializer"); - assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) - .isEqualTo( - "au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer"); - } + @Test + public void serializersApiShouldNotChange() { + assertThat(JacksonSnapshotSerializer.class.getName()) + .isEqualTo("au.com.origin.snapshots.jackson.serializers.JacksonSnapshotSerializer"); + assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) + .isEqualTo( + "au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer"); + } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java index 161a4a4..374ba93 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java @@ -1,30 +1,32 @@ package au.com.origin.snapshots.jackson; import au.com.origin.snapshots.exceptions.SnapshotMatchException; + import java.lang.reflect.Method; import java.util.Optional; import java.util.stream.Stream; +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class ReflectionUtilities { - // FIXME consider guava reflection instead - public static Method getMethod(Class clazz, String methodName) { - try { - return Stream.of(clazz.getDeclaredMethods()) - .filter(method -> method.getName().equals(methodName)) - .findFirst() - .orElseThrow(() -> new NoSuchMethodException("Not Found")); - } catch (NoSuchMethodException e) { - return Optional.ofNullable(clazz.getSuperclass()) - .map(superclass -> getMethod(superclass, methodName)) - .orElseThrow( - () -> - new SnapshotMatchException( - "Could not find method " - + methodName - + " on class " - + clazz - + "\nPlease annotate your test method with @Test and make it without any parameters!")); + // FIXME consider guava reflection instead + public static Method getMethod(Class clazz, String methodName) { + try { + return Stream.of(clazz.getDeclaredMethods()) + .filter(method -> method.getName().equals(methodName)) + .findFirst() + .orElseThrow(() -> new NoSuchMethodException("Not Found")); + } catch (NoSuchMethodException e) { + return Optional.ofNullable(clazz.getSuperclass()) + .map(superclass -> getMethod(superclass, methodName)) + .orElseThrow( + () -> + new SnapshotMatchException( + "Could not find method " + + methodName + + " on class " + + clazz + + "\nPlease annotate your test method with @Test and make it without any parameters!")); + } } - } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java index 0395a40..e17cc99 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java @@ -1,15 +1,16 @@ package au.com.origin.snapshots.jackson.docs; -import java.time.Instant; import lombok.AllArgsConstructor; import lombok.Data; +import java.time.Instant; + // Example base class used by all hibernate entities @Data @AllArgsConstructor public class BaseEntity { - private Long id; - private Instant createdDate; - private Instant lastModifiedDate; - private String somethingElse; + private Long id; + private Instant createdDate; + private Instant lastModifiedDate; + private String somethingElse; } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java index 7a7b83f..fa3fc03 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java @@ -3,23 +3,24 @@ import au.com.origin.snapshots.Expect; import au.com.origin.snapshots.SnapshotVerifier; import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import java.time.Instant; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import java.time.Instant; + public class CustomSerializerTest { - @Test - public void test1(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier( - new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); + @Test + public void test1(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier( + new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect - .serializer(HibernateSnapshotSerializer.class) - .toMatchSnapshot(new BaseEntity(1L, Instant.now(), Instant.now(), "This should render")); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect + .serializer(HibernateSnapshotSerializer.class) + .toMatchSnapshot(new BaseEntity(1L, Instant.now(), Instant.now(), "This should render")); - snapshotVerifier.validateSnapshots(); - } + snapshotVerifier.validateSnapshots(); + } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java index 455b5b9..6deb226 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java @@ -4,35 +4,37 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreType; import com.fasterxml.jackson.databind.ObjectMapper; + import java.time.Instant; import java.util.List; import java.util.Set; public class HibernateSnapshotSerializer extends DeterministicJacksonSnapshotSerializer { - @Override - public void configure(ObjectMapper objectMapper) { - super.configure(objectMapper); + @Override + public void configure(ObjectMapper objectMapper) { + super.configure(objectMapper); - // Ignore Hibernate Lists to prevent infinite recursion - objectMapper.addMixIn(List.class, IgnoreTypeMixin.class); - objectMapper.addMixIn(Set.class, IgnoreTypeMixin.class); + // Ignore Hibernate Lists to prevent infinite recursion + objectMapper.addMixIn(List.class, IgnoreTypeMixin.class); + objectMapper.addMixIn(Set.class, IgnoreTypeMixin.class); - // Ignore Fields that Hibernate generates for us automatically - objectMapper.addMixIn(BaseEntity.class, IgnoreHibernateEntityFields.class); - } + // Ignore Fields that Hibernate generates for us automatically + objectMapper.addMixIn(BaseEntity.class, IgnoreHibernateEntityFields.class); + } - @JsonIgnoreType - class IgnoreTypeMixin {} + @JsonIgnoreType + class IgnoreTypeMixin { + } - abstract class IgnoreHibernateEntityFields { - @JsonIgnore - abstract Long getId(); + abstract class IgnoreHibernateEntityFields { + @JsonIgnore + abstract Long getId(); - @JsonIgnore - abstract Instant getCreatedDate(); + @JsonIgnore + abstract Instant getCreatedDate(); - @JsonIgnore - abstract Instant getLastModifiedDate(); - } + @JsonIgnore + abstract Instant getLastModifiedDate(); + } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java index 9d89ac5..8441a62 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java @@ -8,14 +8,14 @@ import org.skyscreamer.jsonassert.JSONCompareMode; public class JsonAssertReporter implements SnapshotReporter { - @Override - public boolean supportsFormat(String outputFormat) { - return SerializerType.JSON.name().equalsIgnoreCase(outputFormat); - } + @Override + public boolean supportsFormat(String outputFormat) { + return SerializerType.JSON.name().equalsIgnoreCase(outputFormat); + } - @Override - @SneakyThrows - public void report(Snapshot previous, Snapshot current) { - JSONAssert.assertEquals(previous.getBody(), current.getBody(), JSONCompareMode.STRICT); - } + @Override + @SneakyThrows + public void report(Snapshot previous, Snapshot current) { + JSONAssert.assertEquals(previous.getBody(), current.getBody(), JSONCompareMode.STRICT); + } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java index 90a094b..a055e4b 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java @@ -6,14 +6,14 @@ import lombok.SneakyThrows; public class JsonObjectComparator implements SnapshotComparator { - @Override - public boolean matches(Snapshot previous, Snapshot current) { - return asObject(previous.getName(), previous.getBody()) - .equals(asObject(current.getName(), current.getBody())); - } + @SneakyThrows + private static Object asObject(String snapshotName, String json) { + return new ObjectMapper().readValue(json.replaceFirst(snapshotName + "=", ""), Object.class); + } - @SneakyThrows - private static Object asObject(String snapshotName, String json) { - return new ObjectMapper().readValue(json.replaceFirst(snapshotName + "=", ""), Object.class); - } + @Override + public boolean matches(Snapshot previous, Snapshot current) { + return asObject(previous.getName(), previous.getBody()) + .equals(asObject(current.getName(), current.getBody())); + } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java index e6728fb..1a25b4b 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java @@ -4,138 +4,154 @@ import au.com.origin.snapshots.SnapshotVerifier; import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; import au.com.origin.snapshots.serializers.SerializerType; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZonedDateTime; -import java.util.*; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Random; +import java.util.TreeMap; +import java.util.TreeSet; + +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class DeterministicJacksonSnapshotSerializerTest { - @Test - public void shouldSerializeDifferentTypes(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier( - new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer("orderedJson").toMatchSnapshot(new TypeDummy()); - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldSupportJsonFormat() { - Assertions.assertThat(new DeterministicJacksonSnapshotSerializer().getOutputFormat()) - .isEqualTo(SerializerType.JSON.name()); - } - - private Map nonDeterministicMap(Map target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } - }; - - int size = items.size(); - for (int i = 0; i < size; i++) { - String random = pluckRandom(items); - target.put(random, (int) random.charAt(0)); + @Test + public void shouldSerializeDifferentTypes(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier( + new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer("orderedJson").toMatchSnapshot(new TypeDummy()); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldSupportJsonFormat() { + Assertions.assertThat(new DeterministicJacksonSnapshotSerializer().getOutputFormat()) + .isEqualTo(SerializerType.JSON.name()); } - return target; - } - - private Collection nonDeterministicCollection(Collection target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } - }; - - int size = items.size(); - for (int i = 0; i < size; i++) { - target.add(pluckRandom(items)); + + private Map nonDeterministicMap(Map target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + + int size = items.size(); + for (int i = 0; i < size; i++) { + String random = pluckRandom(items); + target.put(random, (int) random.charAt(0)); + } + return target; } - return target; - } - - private String pluckRandom(List array) { - int rnd = new Random().nextInt(array.size()); - return array.remove(rnd); - } - - private enum AnEnum { - F, - A, - D, - E, - G, - B, - C; - } - - private final class TypeDummy { - private final Void aNull = null; - private final Object anObject = new Object(); - private final byte aByte = "A".getBytes()[0]; - private final short aShort = 32767; - private final int anInt = 2147483647; - private final long aLong = 9223372036854775807L; - private final float aFloat = 0.1234567F; - private final double aDouble = 1.123456789123456D; - private final boolean aBoolean = true; - private final char aChar = 'A'; - private final String string = "Hello World"; - private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); - private final LocalDate localDate = LocalDate.parse("2020-10-19"); - private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); - private final ZonedDateTime zonedDateTime = - ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); - private final AnEnum anEnum = AnEnum.A; - private final Optional presentOptional = Optional.of("Hello World"); - private final Optional emptyOptional = Optional.empty(); - private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; - private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); - - // Maps - private final Map hashMap = nonDeterministicMap(new HashMap<>()); - private final Map treeMap = nonDeterministicMap(new TreeMap<>()); - private final Map linkedHashMap = nonDeterministicMap(new LinkedHashMap<>()); - - // Sets - private final Collection linkedHashSet = - nonDeterministicCollection(new LinkedHashSet<>()); - private final Collection hashSet = nonDeterministicCollection(new HashSet<>()); - private final Collection treeSet = nonDeterministicCollection(new TreeSet<>()); - - // Lists - private final Collection arrayList = nonDeterministicCollection(new ArrayList<>()); - private final Collection linkedList = nonDeterministicCollection(new LinkedList<>()); - - // Mixed Maps, Sets, Lists - private final Collection listOfCollections = - new ArrayList() { - { - add(nonDeterministicMap(new LinkedHashMap<>())); - add(nonDeterministicCollection(new LinkedHashSet<>())); - add(nonDeterministicCollection(new LinkedList<>())); - } - }; - } + private Collection nonDeterministicCollection(Collection target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + + int size = items.size(); + for (int i = 0; i < size; i++) { + target.add(pluckRandom(items)); + } + + return target; + } + + private String pluckRandom(List array) { + int rnd = new Random().nextInt(array.size()); + return array.remove(rnd); + } + + private enum AnEnum { + F, + A, + D, + E, + G, + B, + C + } + + private final class TypeDummy { + private final Void aNull = null; + private final Object anObject = new Object(); + private final byte aByte = "A".getBytes()[0]; + private final short aShort = 32767; + private final int anInt = 2147483647; + private final long aLong = 9223372036854775807L; + private final float aFloat = 0.1234567F; + private final double aDouble = 1.123456789123456D; + private final boolean aBoolean = true; + private final char aChar = 'A'; + private final String string = "Hello World"; + private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); + private final LocalDate localDate = LocalDate.parse("2020-10-19"); + private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); + private final ZonedDateTime zonedDateTime = + ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); + private final AnEnum anEnum = AnEnum.A; + private final Optional presentOptional = Optional.of("Hello World"); + private final Optional emptyOptional = Optional.empty(); + private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; + private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); + + // Maps + private final Map hashMap = nonDeterministicMap(new HashMap<>()); + private final Map treeMap = nonDeterministicMap(new TreeMap<>()); + private final Map linkedHashMap = nonDeterministicMap(new LinkedHashMap<>()); + + // Sets + private final Collection linkedHashSet = + nonDeterministicCollection(new LinkedHashSet<>()); + private final Collection hashSet = nonDeterministicCollection(new HashSet<>()); + private final Collection treeSet = nonDeterministicCollection(new TreeSet<>()); + + // Lists + private final Collection arrayList = nonDeterministicCollection(new ArrayList<>()); + private final Collection linkedList = nonDeterministicCollection(new LinkedList<>()); + + // Mixed Maps, Sets, Lists + private final Collection listOfCollections = + new ArrayList() { + { + add(nonDeterministicMap(new LinkedHashMap<>())); + add(nonDeterministicCollection(new LinkedHashSet<>())); + add(nonDeterministicCollection(new LinkedList<>())); + } + }; + } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java index d54550b..a877e80 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java @@ -1,155 +1,174 @@ package au.com.origin.snapshots.jackson.serializers; -import au.com.origin.snapshots.*; +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotHeader; +import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.SnapshotVerifier; import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; import au.com.origin.snapshots.config.SnapshotConfig; import au.com.origin.snapshots.serializers.SerializerType; import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZonedDateTime; -import java.util.*; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.TreeMap; +import java.util.TreeSet; + +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class JacksonSnapshotSerializerTest { - private static final SnapshotConfig DEFAULT_CONFIG = - new PropertyResolvingSnapshotConfig() { - @Override - public SnapshotSerializer getSerializer() { - return new JacksonSnapshotSerializer(); - } - }; - - private SnapshotSerializerContext gen = - new SnapshotSerializerContext( - "test", null, new SnapshotHeader(), JacksonSnapshotSerializerTest.class, null); - - @Test - public void shouldSerializeMap() { - Map map = new HashMap<>(); - map.put("name", "John Doe"); - map.put("age", 40); - - SnapshotSerializer serializer = new JacksonSnapshotSerializer(); - Snapshot result = serializer.apply(map, gen); - Assertions.assertThat(result.getBody()) - .isEqualTo( - "[\n" - + " {\n" - + " \"age\": 40,\n" - + " \"name\": \"John Doe\"\n" - + " }\n" - + "]"); - } - - @Test - public void shouldSerializeDifferentTypes(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(new TypeDummy()); - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldSupportJsonFormat() { - Assertions.assertThat(new JacksonSnapshotSerializer().getOutputFormat()) - .isEqualTo(SerializerType.JSON.name()); - } - - private Map deterministicMap(Map target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } - }; - items.forEach(it -> target.put(it, (int) it.charAt(0))); - return target; - } - - private Collection deterministicCollection(Collection target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } + private static final SnapshotConfig DEFAULT_CONFIG = + new PropertyResolvingSnapshotConfig() { + @Override + public SnapshotSerializer getSerializer() { + return new JacksonSnapshotSerializer(); + } }; - target.addAll(items); - return target; - } - - private enum AnEnum { - F, - A, - D, - E, - G, - B, - C; - } - - private final class TypeDummy { - private final Void aNull = null; - private final Object anObject = new Object(); - private final byte aByte = "A".getBytes()[0]; - private final short aShort = 32767; - private final int anInt = 2147483647; - private final long aLong = 9223372036854775807L; - private final float aFloat = 0.1234567F; - private final double aDouble = 1.123456789123456D; - private final boolean aBoolean = true; - private final char aChar = 'A'; - private final String string = "Hello World"; - private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); - private final LocalDate localDate = LocalDate.parse("2020-10-19"); - private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); - private final ZonedDateTime zonedDateTime = - ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); - private final AnEnum anEnum = AnEnum.A; - private final Optional presentOptional = Optional.of("Hello World"); - private final Optional emptyOptional = Optional.empty(); - private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; - private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); - - // Maps - private final Map hashMap = deterministicMap(new HashMap<>()); - private final Map treeMap = deterministicMap(new TreeMap<>()); - private final Map linkedHashMap = deterministicMap(new LinkedHashMap<>()); - - // Sets - private final Collection linkedHashSet = deterministicCollection(new LinkedHashSet<>()); - private final Collection hashSet = deterministicCollection(new HashSet<>()); - private final Collection treeSet = deterministicCollection(new TreeSet<>()); - - // Lists - private final Collection arrayList = deterministicCollection(new ArrayList<>()); - private final Collection linkedList = deterministicCollection(new LinkedList<>()); - - // Mixed Maps, Sets, Lists - private final Collection listOfCollections = - new ArrayList() { - { - add(deterministicMap(new LinkedHashMap<>())); - add(deterministicCollection(new LinkedHashSet<>())); - add(deterministicCollection(new LinkedList<>())); - } - }; - } + + private final SnapshotSerializerContext gen = + new SnapshotSerializerContext( + "test", null, new SnapshotHeader(), JacksonSnapshotSerializerTest.class, null); + + @Test + public void shouldSerializeMap() { + Map map = new HashMap<>(); + map.put("name", "John Doe"); + map.put("age", 40); + + SnapshotSerializer serializer = new JacksonSnapshotSerializer(); + Snapshot result = serializer.apply(map, gen); + Assertions.assertThat(result.getBody()) + .isEqualTo( + "[\n" + + " {\n" + + " \"age\": 40,\n" + + " \"name\": \"John Doe\"\n" + + " }\n" + + "]"); + } + + @Test + public void shouldSerializeDifferentTypes(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(new TypeDummy()); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldSupportJsonFormat() { + Assertions.assertThat(new JacksonSnapshotSerializer().getOutputFormat()) + .isEqualTo(SerializerType.JSON.name()); + } + + private Map deterministicMap(Map target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + items.forEach(it -> target.put(it, (int) it.charAt(0))); + return target; + } + + private Collection deterministicCollection(Collection target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + target.addAll(items); + return target; + } + + private enum AnEnum { + F, + A, + D, + E, + G, + B, + C + } + + private final class TypeDummy { + private final Void aNull = null; + private final Object anObject = new Object(); + private final byte aByte = "A".getBytes()[0]; + private final short aShort = 32767; + private final int anInt = 2147483647; + private final long aLong = 9223372036854775807L; + private final float aFloat = 0.1234567F; + private final double aDouble = 1.123456789123456D; + private final boolean aBoolean = true; + private final char aChar = 'A'; + private final String string = "Hello World"; + private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); + private final LocalDate localDate = LocalDate.parse("2020-10-19"); + private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); + private final ZonedDateTime zonedDateTime = + ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); + private final AnEnum anEnum = AnEnum.A; + private final Optional presentOptional = Optional.of("Hello World"); + private final Optional emptyOptional = Optional.empty(); + private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; + private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); + + // Maps + private final Map hashMap = deterministicMap(new HashMap<>()); + private final Map treeMap = deterministicMap(new TreeMap<>()); + private final Map linkedHashMap = deterministicMap(new LinkedHashMap<>()); + + // Sets + private final Collection linkedHashSet = deterministicCollection(new LinkedHashSet<>()); + private final Collection hashSet = deterministicCollection(new HashSet<>()); + private final Collection treeSet = deterministicCollection(new TreeSet<>()); + + // Lists + private final Collection arrayList = deterministicCollection(new ArrayList<>()); + private final Collection linkedList = deterministicCollection(new LinkedList<>()); + + // Mixed Maps, Sets, Lists + private final Collection listOfCollections = + new ArrayList() { + { + add(deterministicMap(new LinkedHashMap<>())); + add(deterministicCollection(new LinkedHashSet<>())); + add(deterministicCollection(new LinkedList<>())); + } + }; + } } diff --git a/snapshot-testing-jackson3/pom.xml b/snapshot-testing-jackson3/pom.xml index 3a73d3f..9ee6af6 100644 --- a/snapshot-testing-jackson3/pom.xml +++ b/snapshot-testing-jackson3/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -12,7 +12,7 @@ snapshot-testing-jackson3 finoid-snapshot-testing-jackson3 - + 21 @@ -70,7 +70,7 @@ org.junit.jupiter junit-jupiter-api ${junit.version} - + org.junit.jupiter @@ -94,24 +94,24 @@ test - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + org.assertj @@ -121,25 +121,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java index e5f348a..dba837b 100644 --- a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java +++ b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java @@ -13,8 +13,7 @@ import java.util.stream.Collectors; /** - * Inspired by: - * https://www.stubbornjava.com/posts/creating-a-somewhat-deterministic-jackson-objectmapper + * Inspired by: https://www.stubbornjava.com/posts/creating-a-somewhat-deterministic-jackson-objectmapper. */ @Slf4j public class DeterministicCollectionModule extends SimpleModule { diff --git a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java index a1a1078..1dfa4d6 100644 --- a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java @@ -11,6 +11,7 @@ * *

Note that collections will be ordered which mar or may not be desirable given your use case. */ +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class DeterministicJacksonSnapshotSerializer extends JacksonSnapshotSerializer { /** diff --git a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java index f1a0818..ed4897f 100644 --- a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java @@ -14,14 +14,12 @@ import tools.jackson.databind.cfg.DateTimeFeature; import tools.jackson.databind.json.JsonMapper; -import java.util.Arrays; +import java.util.Collections; import java.util.List; +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class JacksonSnapshotSerializer implements SnapshotSerializer { - private final JsonMapper jsonMapper = createMapper(); - static DefaultPrettyPrinter.Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n"); - private static final DefaultPrettyPrinter pp = new DefaultPrettyPrinter() { { this.indentArraysWith(lfOnlyIndenter); @@ -38,6 +36,7 @@ public DefaultPrettyPrinter createInstance() { return new DefaultPrettyPrinter(this); } }.withArrayIndenter(lfOnlyIndenter); + private final JsonMapper jsonMapper = createMapper(); private JsonMapper createMapper() { JsonMapper.Builder builder = @@ -83,7 +82,7 @@ protected boolean shouldFindAndRegisterModules() { @Override public Snapshot apply(Object object, SnapshotSerializerContext gen) { try { - List objects = Arrays.asList(object); + List objects = Collections.singletonList(object); String body = jsonMapper.writerWithDefaultPrettyPrinter() .writeValueAsString(objects); diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java index 78ed811..788b0b7 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java @@ -1,11 +1,11 @@ package au.com.origin.snapshots.jackson3; -import static org.assertj.core.api.Assertions.assertThat; - import au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer; import au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + /** * These classes are likely defined in snapshot.properties as a string. * @@ -13,12 +13,12 @@ */ public class NoNameChangeTest { - @Test - public void serializersApiShouldNotChange() { - assertThat(JacksonSnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer"); - assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) - .isEqualTo( - "au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer"); - } + @Test + public void serializersApiShouldNotChange() { + assertThat(JacksonSnapshotSerializer.class.getName()) + .isEqualTo("au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer"); + assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) + .isEqualTo( + "au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer"); + } } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java index b129663..3c2b037 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java @@ -1,30 +1,32 @@ package au.com.origin.snapshots.jackson3; import au.com.origin.snapshots.exceptions.SnapshotMatchException; + import java.lang.reflect.Method; import java.util.Optional; import java.util.stream.Stream; +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class ReflectionUtilities { - // FIXME consider guava reflection instead - public static Method getMethod(Class clazz, String methodName) { - try { - return Stream.of(clazz.getDeclaredMethods()) - .filter(method -> method.getName().equals(methodName)) - .findFirst() - .orElseThrow(() -> new NoSuchMethodException("Not Found")); - } catch (NoSuchMethodException e) { - return Optional.ofNullable(clazz.getSuperclass()) - .map(superclass -> getMethod(superclass, methodName)) - .orElseThrow( - () -> - new SnapshotMatchException( - "Could not find method " - + methodName - + " on class " - + clazz - + "\nPlease annotate your test method with @Test and make it without any parameters!")); + // FIXME consider guava reflection instead + public static Method getMethod(Class clazz, String methodName) { + try { + return Stream.of(clazz.getDeclaredMethods()) + .filter(method -> method.getName().equals(methodName)) + .findFirst() + .orElseThrow(() -> new NoSuchMethodException("Not Found")); + } catch (NoSuchMethodException e) { + return Optional.ofNullable(clazz.getSuperclass()) + .map(superclass -> getMethod(superclass, methodName)) + .orElseThrow( + () -> + new SnapshotMatchException( + "Could not find method " + + methodName + + " on class " + + clazz + + "\nPlease annotate your test method with @Test and make it without any parameters!")); + } } - } } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java index 46da813..9b9c8f0 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java @@ -1,15 +1,16 @@ package au.com.origin.snapshots.jackson3.docs; -import java.time.Instant; import lombok.AllArgsConstructor; import lombok.Data; +import java.time.Instant; + // Example base class used by all hibernate entities @Data @AllArgsConstructor public class BaseEntity { - private Long id; - private Instant createdDate; - private Instant lastModifiedDate; - private String somethingElse; + private Long id; + private Instant createdDate; + private Instant lastModifiedDate; + private String somethingElse; } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java index 2d2caa5..d41298e 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java @@ -3,23 +3,24 @@ import au.com.origin.snapshots.Expect; import au.com.origin.snapshots.SnapshotVerifier; import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import java.time.Instant; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import java.time.Instant; + public class CustomSerializerTest { - @Test - public void test1(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier( - new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); + @Test + public void test1(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier( + new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect - .serializer(HibernateSnapshotSerializer.class) - .toMatchSnapshot(new BaseEntity(1L, Instant.now(), Instant.now(), "This should render")); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect + .serializer(HibernateSnapshotSerializer.class) + .toMatchSnapshot(new BaseEntity(1L, Instant.now(), Instant.now(), "This should render")); - snapshotVerifier.validateSnapshots(); - } + snapshotVerifier.validateSnapshots(); + } } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java index f2a157a..9c13d2d 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java @@ -8,14 +8,14 @@ import org.skyscreamer.jsonassert.JSONCompareMode; public class JsonAssertReporter implements SnapshotReporter { - @Override - public boolean supportsFormat(String outputFormat) { - return SerializerType.JSON.name().equalsIgnoreCase(outputFormat); - } + @Override + public boolean supportsFormat(String outputFormat) { + return SerializerType.JSON.name().equalsIgnoreCase(outputFormat); + } - @Override - @SneakyThrows - public void report(Snapshot previous, Snapshot current) { - JSONAssert.assertEquals(previous.getBody(), current.getBody(), JSONCompareMode.STRICT); - } + @Override + @SneakyThrows + public void report(Snapshot previous, Snapshot current) { + JSONAssert.assertEquals(previous.getBody(), current.getBody(), JSONCompareMode.STRICT); + } } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java index 3a61708..996fd6b 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java @@ -6,14 +6,14 @@ import tools.jackson.databind.json.JsonMapper; public class JsonObjectComparator implements SnapshotComparator { - @Override - public boolean matches(Snapshot previous, Snapshot current) { - return asObject(previous.getName(), previous.getBody()) - .equals(asObject(current.getName(), current.getBody())); - } + @SneakyThrows + private static Object asObject(String snapshotName, String json) { + return new JsonMapper().readValue(json.replaceFirst(snapshotName + "=", ""), Object.class); + } - @SneakyThrows - private static Object asObject(String snapshotName, String json) { - return new JsonMapper().readValue(json.replaceFirst(snapshotName + "=", ""), Object.class); - } + @Override + public boolean matches(Snapshot previous, Snapshot current) { + return asObject(previous.getName(), previous.getBody()) + .equals(asObject(current.getName(), current.getBody())); + } } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java index 788917c..9ac738a 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java @@ -4,138 +4,154 @@ import au.com.origin.snapshots.SnapshotVerifier; import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; import au.com.origin.snapshots.serializers.SerializerType; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZonedDateTime; -import java.util.*; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Random; +import java.util.TreeMap; +import java.util.TreeSet; + +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class DeterministicJacksonSnapshotSerializerTest { - @Test - public void shouldSerializeDifferentTypes(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier( - new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.serializer("orderedJson").toMatchSnapshot(new TypeDummy()); - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldSupportJsonFormat() { - Assertions.assertThat(new DeterministicJacksonSnapshotSerializer().getOutputFormat()) - .isEqualTo(SerializerType.JSON.name()); - } - - private Map nonDeterministicMap(Map target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } - }; - - int size = items.size(); - for (int i = 0; i < size; i++) { - String random = pluckRandom(items); - target.put(random, (int) random.charAt(0)); + @Test + public void shouldSerializeDifferentTypes(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier( + new PropertyResolvingSnapshotConfig(), testInfo.getTestClass().get(), false); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.serializer("orderedJson").toMatchSnapshot(new TypeDummy()); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldSupportJsonFormat() { + Assertions.assertThat(new DeterministicJacksonSnapshotSerializer().getOutputFormat()) + .isEqualTo(SerializerType.JSON.name()); } - return target; - } - - private Collection nonDeterministicCollection(Collection target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } - }; - - int size = items.size(); - for (int i = 0; i < size; i++) { - target.add(pluckRandom(items)); + + private Map nonDeterministicMap(Map target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + + int size = items.size(); + for (int i = 0; i < size; i++) { + String random = pluckRandom(items); + target.put(random, (int) random.charAt(0)); + } + return target; } - return target; - } - - private String pluckRandom(List array) { - int rnd = new Random().nextInt(array.size()); - return array.remove(rnd); - } - - private enum AnEnum { - F, - A, - D, - E, - G, - B, - C; - } - - private final class TypeDummy { - private final Void aNull = null; - private final Object anObject = new Object(); - private final byte aByte = "A".getBytes()[0]; - private final short aShort = 32767; - private final int anInt = 2147483647; - private final long aLong = 9223372036854775807L; - private final float aFloat = 0.1234567F; - private final double aDouble = 1.123456789123456D; - private final boolean aBoolean = true; - private final char aChar = 'A'; - private final String string = "Hello World"; - private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); - private final LocalDate localDate = LocalDate.parse("2020-10-19"); - private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); - private final ZonedDateTime zonedDateTime = - ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); - private final AnEnum anEnum = AnEnum.A; - private final Optional presentOptional = Optional.of("Hello World"); - private final Optional emptyOptional = Optional.empty(); - private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; - private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); - - // Maps - private final Map hashMap = nonDeterministicMap(new HashMap<>()); - private final Map treeMap = nonDeterministicMap(new TreeMap<>()); - private final Map linkedHashMap = nonDeterministicMap(new LinkedHashMap<>()); - - // Sets - private final Collection linkedHashSet = - nonDeterministicCollection(new LinkedHashSet<>()); - private final Collection hashSet = nonDeterministicCollection(new HashSet<>()); - private final Collection treeSet = nonDeterministicCollection(new TreeSet<>()); - - // Lists - private final Collection arrayList = nonDeterministicCollection(new ArrayList<>()); - private final Collection linkedList = nonDeterministicCollection(new LinkedList<>()); - - // Mixed Maps, Sets, Lists - private final Collection listOfCollections = - new ArrayList() { - { - add(nonDeterministicMap(new LinkedHashMap<>())); - add(nonDeterministicCollection(new LinkedHashSet<>())); - add(nonDeterministicCollection(new LinkedList<>())); - } - }; - } + private Collection nonDeterministicCollection(Collection target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + + int size = items.size(); + for (int i = 0; i < size; i++) { + target.add(pluckRandom(items)); + } + + return target; + } + + private String pluckRandom(List array) { + int rnd = new Random().nextInt(array.size()); + return array.remove(rnd); + } + + private enum AnEnum { + F, + A, + D, + E, + G, + B, + C + } + + private final class TypeDummy { + private final Void aNull = null; + private final Object anObject = new Object(); + private final byte aByte = "A".getBytes()[0]; + private final short aShort = 32767; + private final int anInt = 2147483647; + private final long aLong = 9223372036854775807L; + private final float aFloat = 0.1234567F; + private final double aDouble = 1.123456789123456D; + private final boolean aBoolean = true; + private final char aChar = 'A'; + private final String string = "Hello World"; + private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); + private final LocalDate localDate = LocalDate.parse("2020-10-19"); + private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); + private final ZonedDateTime zonedDateTime = + ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); + private final AnEnum anEnum = AnEnum.A; + private final Optional presentOptional = Optional.of("Hello World"); + private final Optional emptyOptional = Optional.empty(); + private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; + private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); + + // Maps + private final Map hashMap = nonDeterministicMap(new HashMap<>()); + private final Map treeMap = nonDeterministicMap(new TreeMap<>()); + private final Map linkedHashMap = nonDeterministicMap(new LinkedHashMap<>()); + + // Sets + private final Collection linkedHashSet = + nonDeterministicCollection(new LinkedHashSet<>()); + private final Collection hashSet = nonDeterministicCollection(new HashSet<>()); + private final Collection treeSet = nonDeterministicCollection(new TreeSet<>()); + + // Lists + private final Collection arrayList = nonDeterministicCollection(new ArrayList<>()); + private final Collection linkedList = nonDeterministicCollection(new LinkedList<>()); + + // Mixed Maps, Sets, Lists + private final Collection listOfCollections = + new ArrayList() { + { + add(nonDeterministicMap(new LinkedHashMap<>())); + add(nonDeterministicCollection(new LinkedHashSet<>())); + add(nonDeterministicCollection(new LinkedList<>())); + } + }; + } } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java index e3d2a89..cdf3bba 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java @@ -1,155 +1,174 @@ package au.com.origin.snapshots.jackson3.serializers.v1; -import au.com.origin.snapshots.*; +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.Snapshot; +import au.com.origin.snapshots.SnapshotHeader; +import au.com.origin.snapshots.SnapshotSerializerContext; +import au.com.origin.snapshots.SnapshotVerifier; import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; import au.com.origin.snapshots.config.SnapshotConfig; import au.com.origin.snapshots.serializers.SerializerType; import au.com.origin.snapshots.serializers.SnapshotSerializer; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZonedDateTime; -import java.util.*; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.TreeMap; +import java.util.TreeSet; + +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class JacksonSnapshotSerializerTest { - private static final SnapshotConfig DEFAULT_CONFIG = - new PropertyResolvingSnapshotConfig() { - @Override - public SnapshotSerializer getSerializer() { - return new JacksonSnapshotSerializer(); - } - }; - - private SnapshotSerializerContext gen = - new SnapshotSerializerContext( - "test", null, new SnapshotHeader(), JacksonSnapshotSerializerTest.class, null); - - @Test - public void shouldSerializeMap() { - Map map = new HashMap<>(); - map.put("name", "John Doe"); - map.put("age", 40); - - SnapshotSerializer serializer = new JacksonSnapshotSerializer(); - Snapshot result = serializer.apply(map, gen); - Assertions.assertThat(result.getBody()) - .isEqualTo( - "[\n" - + " {\n" - + " \"age\" : 40,\n" - + " \"name\" : \"John Doe\"\n" - + " }\n" - + "]"); - } - - @Test - public void shouldSerializeDifferentTypes(TestInfo testInfo) { - SnapshotVerifier snapshotVerifier = - new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot(new TypeDummy()); - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldSupportJsonFormat() { - Assertions.assertThat(new JacksonSnapshotSerializer().getOutputFormat()) - .isEqualTo(SerializerType.JSON.name()); - } - - private Map deterministicMap(Map target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } - }; - items.forEach(it -> target.put(it, (int) it.charAt(0))); - return target; - } - - private Collection deterministicCollection(Collection target) { - final List items = - new ArrayList() { - { - add("f"); - add("a"); - add("d"); - add("e"); - add("g"); - add("b"); - add("c"); - } + private static final SnapshotConfig DEFAULT_CONFIG = + new PropertyResolvingSnapshotConfig() { + @Override + public SnapshotSerializer getSerializer() { + return new JacksonSnapshotSerializer(); + } }; - target.addAll(items); - return target; - } - - private enum AnEnum { - F, - A, - D, - E, - G, - B, - C; - } - - private final class TypeDummy { - private final Void aNull = null; - private final Object anObject = new Object(); - private final byte aByte = "A".getBytes()[0]; - private final short aShort = 32767; - private final int anInt = 2147483647; - private final long aLong = 9223372036854775807L; - private final float aFloat = 0.1234567F; - private final double aDouble = 1.123456789123456D; - private final boolean aBoolean = true; - private final char aChar = 'A'; - private final String string = "Hello World"; - private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); - private final LocalDate localDate = LocalDate.parse("2020-10-19"); - private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); - private final ZonedDateTime zonedDateTime = - ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); - private final AnEnum anEnum = AnEnum.A; - private final Optional presentOptional = Optional.of("Hello World"); - private final Optional emptyOptional = Optional.empty(); - private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; - private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); - - // Maps - private final Map hashMap = deterministicMap(new HashMap<>()); - private final Map treeMap = deterministicMap(new TreeMap<>()); - private final Map linkedHashMap = deterministicMap(new LinkedHashMap<>()); - - // Sets - private final Collection linkedHashSet = deterministicCollection(new LinkedHashSet<>()); - private final Collection hashSet = deterministicCollection(new HashSet<>()); - private final Collection treeSet = deterministicCollection(new TreeSet<>()); - - // Lists - private final Collection arrayList = deterministicCollection(new ArrayList<>()); - private final Collection linkedList = deterministicCollection(new LinkedList<>()); - - // Mixed Maps, Sets, Lists - private final Collection listOfCollections = - new ArrayList() { - { - add(deterministicMap(new LinkedHashMap<>())); - add(deterministicCollection(new LinkedHashSet<>())); - add(deterministicCollection(new LinkedList<>())); - } - }; - } + + private final SnapshotSerializerContext gen = + new SnapshotSerializerContext( + "test", null, new SnapshotHeader(), JacksonSnapshotSerializerTest.class, null); + + @Test + public void shouldSerializeMap() { + Map map = new HashMap<>(); + map.put("name", "John Doe"); + map.put("age", 40); + + SnapshotSerializer serializer = new JacksonSnapshotSerializer(); + Snapshot result = serializer.apply(map, gen); + Assertions.assertThat(result.getBody()) + .isEqualTo( + "[\n" + + " {\n" + + " \"age\" : 40,\n" + + " \"name\" : \"John Doe\"\n" + + " }\n" + + "]"); + } + + @Test + public void shouldSerializeDifferentTypes(TestInfo testInfo) { + SnapshotVerifier snapshotVerifier = + new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get()); + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot(new TypeDummy()); + snapshotVerifier.validateSnapshots(); + } + + @Test + void shouldSupportJsonFormat() { + Assertions.assertThat(new JacksonSnapshotSerializer().getOutputFormat()) + .isEqualTo(SerializerType.JSON.name()); + } + + private Map deterministicMap(Map target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + items.forEach(it -> target.put(it, (int) it.charAt(0))); + return target; + } + + private Collection deterministicCollection(Collection target) { + final List items = + new ArrayList() { + { + add("f"); + add("a"); + add("d"); + add("e"); + add("g"); + add("b"); + add("c"); + } + }; + target.addAll(items); + return target; + } + + private enum AnEnum { + F, + A, + D, + E, + G, + B, + C + } + + private final class TypeDummy { + private final Void aNull = null; + private final Object anObject = new Object(); + private final byte aByte = "A".getBytes()[0]; + private final short aShort = 32767; + private final int anInt = 2147483647; + private final long aLong = 9223372036854775807L; + private final float aFloat = 0.1234567F; + private final double aDouble = 1.123456789123456D; + private final boolean aBoolean = true; + private final char aChar = 'A'; + private final String string = "Hello World"; + private final Date date = Date.from(Instant.parse("2020-10-19T22:21:07.103Z")); + private final LocalDate localDate = LocalDate.parse("2020-10-19"); + private final LocalDateTime localDateTime = LocalDateTime.parse("2020-10-19T22:21:07.103"); + private final ZonedDateTime zonedDateTime = + ZonedDateTime.parse("2020-04-19T22:21:07.103+10:00[Australia/Melbourne]"); + private final AnEnum anEnum = AnEnum.A; + private final Optional presentOptional = Optional.of("Hello World"); + private final Optional emptyOptional = Optional.empty(); + private final String[] stringArray = {"f", "a", "d", "e", "g", "b", "c"}; + private final Object[] anEnumArray = Arrays.stream(AnEnum.values()).toArray(); + + // Maps + private final Map hashMap = deterministicMap(new HashMap<>()); + private final Map treeMap = deterministicMap(new TreeMap<>()); + private final Map linkedHashMap = deterministicMap(new LinkedHashMap<>()); + + // Sets + private final Collection linkedHashSet = deterministicCollection(new LinkedHashSet<>()); + private final Collection hashSet = deterministicCollection(new HashSet<>()); + private final Collection treeSet = deterministicCollection(new TreeSet<>()); + + // Lists + private final Collection arrayList = deterministicCollection(new ArrayList<>()); + private final Collection linkedList = deterministicCollection(new LinkedList<>()); + + // Mixed Maps, Sets, Lists + private final Collection listOfCollections = + new ArrayList() { + { + add(deterministicMap(new LinkedHashMap<>())); + add(deterministicCollection(new LinkedHashSet<>())); + add(deterministicCollection(new LinkedList<>())); + } + }; + } } diff --git a/snapshot-testing-junit5/pom.xml b/snapshot-testing-junit5/pom.xml index d5bba4f..ffce497 100644 --- a/snapshot-testing-junit5/pom.xml +++ b/snapshot-testing-junit5/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -12,7 +12,7 @@ snapshot-testing-junit5 finoid-snapshot-testing-junit5 - + 21 @@ -61,7 +61,7 @@ org.junit.jupiter junit-jupiter-api ${junit.version} - + org.junit.jupiter @@ -85,24 +85,24 @@ test - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + org.assertj @@ -112,12 +112,12 @@ - - - - - - + + + + + + com.fasterxml.jackson.core diff --git a/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java b/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java index 17f67be..d3e05b5 100644 --- a/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java +++ b/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java @@ -8,9 +8,7 @@ import au.com.origin.snapshots.exceptions.SnapshotMatchException; import au.com.origin.snapshots.logging.LoggingHelper; import au.com.origin.snapshots.utils.ReflectionUtils; -import java.lang.reflect.Field; import lombok.extern.slf4j.Slf4j; - import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; @@ -21,108 +19,109 @@ import org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor; import org.junit.jupiter.engine.descriptor.ClassTestDescriptor; +import java.lang.reflect.Field; + @Slf4j +@SuppressWarnings({"checkstyle:all", "EmptyBlockTag"}) // TODO (nw) rewrite public class SnapshotExtension implements AfterAllCallback, - BeforeAllCallback, - SnapshotConfigInjector, - ParameterResolver, - BeforeEachCallback { + BeforeAllCallback, + SnapshotConfigInjector, + ParameterResolver, + BeforeEachCallback { - private SnapshotVerifier snapshotVerifier; + private SnapshotVerifier snapshotVerifier; - @Override - public void beforeAll(ExtensionContext context) { - // don't fail if a test is run alone from the IDE for example - boolean failOnOrphans = shouldFailOnOrphans(context); - Class testClass = - context - .getTestClass() - .orElseThrow(() -> new SnapshotMatchException("Unable to locate Test class")); - this.snapshotVerifier = new SnapshotVerifier(getSnapshotConfig(), testClass, failOnOrphans); - } + @Override + public void beforeAll(ExtensionContext context) { + // don't fail if a test is run alone from the IDE for example + boolean failOnOrphans = shouldFailOnOrphans(context); + Class testClass = + context + .getTestClass() + .orElseThrow(() -> new SnapshotMatchException("Unable to locate Test class")); + this.snapshotVerifier = new SnapshotVerifier(getSnapshotConfig(), testClass, failOnOrphans); + } - @Override - public void afterAll(ExtensionContext context) { - this.snapshotVerifier.validateSnapshots(); - } + @Override + public void afterAll(ExtensionContext context) { + this.snapshotVerifier.validateSnapshots(); + } - @Override - public SnapshotConfig getSnapshotConfig() { - return new PropertyResolvingSnapshotConfig(); - } + @Override + public SnapshotConfig getSnapshotConfig() { + return new PropertyResolvingSnapshotConfig(); + } - /** - * FIXME This is a hack until I find the correct way to determine if a test run is individual or - * as part of a class - * - * @param context - * @return - */ - private boolean shouldFailOnOrphans(ExtensionContext context) { - try { - Field field = context.getClass().getSuperclass().getDeclaredField("testDescriptor"); - field.setAccessible(true); - Object testDescriptor = field.get(context); - if (testDescriptor instanceof ClassTestDescriptor) { // Junit 5.3.2 - ClassTestDescriptor classTestDescriptor = (ClassTestDescriptor) testDescriptor; - return classTestDescriptor.getChildren().size() > 1; - } else if (testDescriptor instanceof ClassBasedTestDescriptor) { // Junit 5.7.2 - ClassBasedTestDescriptor classTestDescriptor = (ClassBasedTestDescriptor) testDescriptor; - return classTestDescriptor.getChildren().size() > 1; - } - } catch (Exception e) { - log.error( - "FAILED: (Java Snapshot Testing) Unable to get JUnit5 ClassTestDescriptor or ClassBasedTestDescriptor!\n" - + "Ensure you are using Junit5 >= 5.3.2\n" - + "This may be due to JUnit5 changing their private api as we use reflection to access it\n" - + "Log a support ticket https://github.com/origin-energy/java-snapshot-testing/issues and supply your JUnit5 version\n" - + "Setting failOnOrphans=true as this is the safest option." - + "This means that running a test alone (say from the IDE) will fail the snapshot, you need to run the entire class.", - e); + /** + * FIXME This is a hack until I find the correct way to determine if a test run is individual or + * as part of a class + * + * @param context + * @return + */ + private boolean shouldFailOnOrphans(ExtensionContext context) { + try { + Field field = context.getClass().getSuperclass().getDeclaredField("testDescriptor"); + field.setAccessible(true); + Object testDescriptor = field.get(context); + if (testDescriptor instanceof ClassTestDescriptor classTestDescriptor) { // Junit 5.3.2 + return classTestDescriptor.getChildren().size() > 1; + } else if (testDescriptor instanceof ClassBasedTestDescriptor classTestDescriptor) { // Junit 5.7.2 + return classTestDescriptor.getChildren().size() > 1; + } + } catch (Exception e) { + log.error( + "FAILED: (Java Snapshot Testing) Unable to get JUnit5 ClassTestDescriptor or ClassBasedTestDescriptor!\n" + + "Ensure you are using Junit5 >= 5.3.2\n" + + "This may be due to JUnit5 changing their private api as we use reflection to access it\n" + + "Log a support ticket https://github.com/origin-energy/java-snapshot-testing/issues and supply your JUnit5 version\n" + + "Setting failOnOrphans=true as this is the safest option." + + "This means that running a test alone (say from the IDE) will fail the snapshot, you need to run the entire class.", + e); + } + return true; } - return true; - } - @Override - public boolean supportsParameter( - ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - boolean supports = parameterContext.getParameter().getType() == Expect.class; - if (supports) { - LoggingHelper.deprecatedV5( - log, - "Injecting 'Expect' via method a argument is no longer recommended. Consider using instance variable injection instead."); + @Override + public boolean supportsParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + boolean supports = parameterContext.getParameter().getType() == Expect.class; + if (supports) { + LoggingHelper.deprecatedV5( + log, + "Injecting 'Expect' via method a argument is no longer recommended. Consider using instance variable injection instead."); + } + return supports; } - return supports; - } - @Override - public Object resolveParameter( - ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - return new Expect( - snapshotVerifier, - extensionContext - .getTestMethod() - .orElseThrow(() -> new RuntimeException("getTestMethod() is missing"))); - } + @Override + public Object resolveParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return new Expect( + snapshotVerifier, + extensionContext + .getTestMethod() + .orElseThrow(() -> new RuntimeException("getTestMethod() is missing"))); + } - @Override - public void beforeEach(ExtensionContext context) { - if (context.getTestInstance().isPresent() && context.getTestMethod().isPresent()) { - ReflectionUtils.findFieldByPredicate( - context.getTestClass().get(), (field) -> field.getType() == Expect.class) - .ifPresent( - (field) -> { - Expect expect = Expect.of(snapshotVerifier, context.getTestMethod().get()); - ReflectionUtils.makeAccessible(field); - try { - field.set(context.getTestInstance().get(), expect); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); + @Override + public void beforeEach(ExtensionContext context) { + if (context.getTestInstance().isPresent() && context.getTestMethod().isPresent()) { + ReflectionUtils.findFieldByPredicate( + context.getTestClass().get(), (field) -> field.getType() == Expect.class) + .ifPresent( + (field) -> { + Expect expect = Expect.of(snapshotVerifier, context.getTestMethod().get()); + ReflectionUtils.makeAccessible(field); + try { + field.set(context.getTestInstance().get(), expect); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + }); + } } - } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java index 8b89737..5647c54 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java @@ -8,17 +8,17 @@ @ExtendWith({SnapshotExtension.class}) public class BaseClassTest { - class TestBase { - Expect expect; - } + class TestBase { + Expect expect; + } - @Nested - @ExtendWith(SnapshotExtension.class) - class NestedClass extends TestBase { + @Nested + @ExtendWith(SnapshotExtension.class) + class NestedClass extends TestBase { - @Test - public void helloWorldTest() { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } } - } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java index 7267329..c0df8cb 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java @@ -1,52 +1,54 @@ package au.com.origin.snapshots; -import static org.assertj.core.api.Assertions.assertThat; - import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; + +@SuppressWarnings("checkstyle:HideUtilityClassConstructor") @ExtendWith({SnapshotExtension.class}) public class NestedClassTest { - @AfterAll - public static void afterAll() { - Path path = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest.snap"); - assertThat(Files.exists(path)).isFalse(); - } + @AfterAll + public static void afterAll() { + Path path = + Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest.snap"); + assertThat(Files.exists(path)).isFalse(); + } - @Nested - class NestedClassWithExpectArgument { + @Nested + class NestedClassWithExpectArgument { - @Test - public void helloWorldTest(Expect expect) { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest(Expect expect) { + expect.toMatchSnapshot("Hello World"); + } } - } - @Nested - class NestedClassWithoutSnapshot { + @Nested + class NestedClassWithoutSnapshot { - @Test - public void helloWorldTest() { - assertThat(true).isTrue(); + @Test + public void helloWorldTest() { + assertThat(true).isTrue(); + } } - } - @Nested - class NestedClassWithExpectInstance { + @Nested + class NestedClassWithExpectInstance { - Expect expect; + Expect expect; - @Test - public void helloWorldTest() { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } } - } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java index d4ac92c..87c85e9 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java @@ -1,35 +1,37 @@ package au.com.origin.snapshots; -import static org.assertj.core.api.Assertions.assertThat; - import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; + +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class NestedClassTestWithExtends { - @AfterAll - public static void afterAll() { - Path path = - Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); - assertThat(Files.exists(path)).isFalse(); - } + @AfterAll + public static void afterAll() { + Path path = + Paths.get( + "src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); + assertThat(Files.exists(path)).isFalse(); + } - @ExtendWith(SnapshotExtension.class) - @Nested - class NestedClass { + @ExtendWith(SnapshotExtension.class) + @Nested + class NestedClass { - Expect expect; + Expect expect; - @Test - public void helloWorldTest() { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } } - } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java index e1c4044..d8eb3ec 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java @@ -8,37 +8,37 @@ @ExtendWith(SnapshotExtension.class) public class SnapshotExtensionUsedTest { - private Expect expect; - - @Test - public void shouldUseExtension(Expect expect) { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void shouldUseExtensionAgain(Expect expect) { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void shouldUseExtensionViaInstanceVariable() { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void shouldUseExtensionAgainViaInstanceVariable() { - expect.toMatchSnapshot("Hello World"); - } - - @SnapshotName("hello_world") - @Test - public void snapshotWithName() { - expect.toMatchSnapshot("Hello World"); - } - - @SnapshotName("hello_world_2") - @Test - public void snapshotWithNameAgain() { - expect.toMatchSnapshot("Hello World"); - } + private Expect expect; + + @Test + public void shouldUseExtension(Expect expect) { + expect.toMatchSnapshot("Hello World"); + } + + @Test + public void shouldUseExtensionAgain(Expect expect) { + expect.toMatchSnapshot("Hello World"); + } + + @Test + public void shouldUseExtensionViaInstanceVariable() { + expect.toMatchSnapshot("Hello World"); + } + + @Test + public void shouldUseExtensionAgainViaInstanceVariable() { + expect.toMatchSnapshot("Hello World"); + } + + @SnapshotName("hello_world") + @Test + public void snapshotWithName() { + expect.toMatchSnapshot("Hello World"); + } + + @SnapshotName("hello_world_2") + @Test + public void snapshotWithNameAgain() { + expect.toMatchSnapshot("Hello World"); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java index 0b282e7..3bd1d9d 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java @@ -2,50 +2,51 @@ import au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer; import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.util.stream.Stream; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import java.util.stream.Stream; + @ExtendWith({SnapshotExtension.class}) class SnapshotParameterTest { - private Expect expect; - - static Stream testData() { - - return Stream.of( - Arguments.of("Scenario2", "test input 1"), - Arguments.of("Scenario2", "test input 1"), - Arguments.of("Scenario2", "test input 1"), - Arguments.of("Scenario3", "test input 2"), - Arguments.of("Scenario3", "test input 2")); - } - - @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") - void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { - expect.toMatchSnapshot("Duplicates are OK"); - expect.toMatchSnapshot("Duplicates are OK"); - expect.scenario("Scenario1").toMatchSnapshot("Additional snapshots need to include a scenario"); - expect - .serializer(JacksonSnapshotSerializer.class) - .scenario(scenario) - .toMatchSnapshot(testInput); - } - - @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") - void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { - this.expect.toMatchSnapshot("Duplicates are OK"); - this.expect.toMatchSnapshot("Duplicates are OK"); - this.expect - .scenario("Scenario1") - .toMatchSnapshot("Additional snapshots need to include a scenario"); - this.expect - .serializer(JacksonSnapshotSerializer.class) - .scenario(scenario) - .toMatchSnapshot(testInput); - } + private Expect expect; + + static Stream testData() { + + return Stream.of( + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario3", "test input 2"), + Arguments.of("Scenario3", "test input 2")); + } + + @ParameterizedTest + @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { + expect.toMatchSnapshot("Duplicates are OK"); + expect.toMatchSnapshot("Duplicates are OK"); + expect.scenario("Scenario1").toMatchSnapshot("Additional snapshots need to include a scenario"); + expect + .serializer(JacksonSnapshotSerializer.class) + .scenario(scenario) + .toMatchSnapshot(testInput); + } + + @ParameterizedTest + @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { + this.expect.toMatchSnapshot("Duplicates are OK"); + this.expect.toMatchSnapshot("Duplicates are OK"); + this.expect + .scenario("Scenario1") + .toMatchSnapshot("Additional snapshots need to include a scenario"); + this.expect + .serializer(JacksonSnapshotSerializer.class) + .scenario(scenario) + .toMatchSnapshot(testInput); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap deleted file mode 100644 index e70d0b5..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTest$NestedClassWithExpectArgument.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java index 841635c..19842d9 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java @@ -11,22 +11,22 @@ // Notice we aren't using any framework extensions public class CustomFrameworkExample { - private static SnapshotVerifier snapshotVerifier; + private static SnapshotVerifier snapshotVerifier; - @BeforeAll - static void beforeAll() { - snapshotVerifier = - new SnapshotVerifier(new PropertyResolvingSnapshotConfig(), CustomFrameworkExample.class); - } + @BeforeAll + static void beforeAll() { + snapshotVerifier = + new SnapshotVerifier(new PropertyResolvingSnapshotConfig(), CustomFrameworkExample.class); + } - @AfterAll - static void afterAll() { - snapshotVerifier.validateSnapshots(); - } + @AfterAll + static void afterAll() { + snapshotVerifier.validateSnapshots(); + } - @Test - void shouldMatchSnapshotOne(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Hello World"); - } + @Test + void shouldMatchSnapshotOne(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Hello World"); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java index 1f0fece..28ce52e 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java @@ -11,8 +11,8 @@ @UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) public class CustomSnapshotConfigExample { - @Test - public void myTest(Expect expect) { - expect.toMatchSnapshot("hello world"); - } + @Test + public void myTest(Expect expect) { + expect.toMatchSnapshot("hello world"); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java index 1fe4b8a..b2593ce 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java @@ -9,18 +9,18 @@ @ExtendWith({SnapshotExtension.class}) public class JUnit5Example { - // Option 1: inject Expect as an instance variable - private Expect expect; + // Option 1: inject Expect as an instance variable + private Expect expect; - @Test - public void myTest1() { - // Verify your snapshot - expect.toMatchSnapshot("Hello World"); - } + @Test + public void myTest1() { + // Verify your snapshot + expect.toMatchSnapshot("Hello World"); + } - // Option 2: inject Expect into the method signature - @Test - public void myTest2(Expect expect) { - expect.toMatchSnapshot("Hello World Again"); - } + // Option 2: inject Expect into the method signature + @Test + public void myTest2(Expect expect) { + expect.toMatchSnapshot("Hello World Again"); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java index eae0ab2..bd0be20 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java @@ -10,25 +10,25 @@ @UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) public class JUnit5ResolutionHierarchyExample { - private Expect expect; + private Expect expect; - @Test - public void aliasMethodTest() { - expect - .serializer("json") // <------ Using snapshot.properties - .toMatchSnapshot(new TestObject()); - } + @Test + public void aliasMethodTest() { + expect + .serializer("json") // <------ Using snapshot.properties + .toMatchSnapshot(new TestObject()); + } - @Test - public void customSerializerTest() { - expect - .serializer(UppercaseToStringSerializer.class) // <------ Using custom serializer - .toMatchSnapshot(new TestObject()); - } + @Test + public void customSerializerTest() { + expect + .serializer(UppercaseToStringSerializer.class) // <------ Using custom serializer + .toMatchSnapshot(new TestObject()); + } - // Read from LowercaseToStringSnapshotConfig defined on the class - @Test - public void lowercaseTest() { - expect.toMatchSnapshot(new TestObject()); - } + // Read from LowercaseToStringSnapshotConfig defined on the class + @Test + public void lowercaseTest() { + expect.toMatchSnapshot(new TestObject()); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java index d333eca..5c83846 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java @@ -6,13 +6,13 @@ import au.com.origin.snapshots.serializers.SnapshotSerializer; public class LowercaseToStringSerializer implements SnapshotSerializer { - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - return gen.toSnapshot(object.toString().toLowerCase()); - } + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + return gen.toSnapshot(object.toString().toLowerCase()); + } - @Override - public String getOutputFormat() { - return SerializerType.TEXT.name(); - } + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java index aac8eb5..8f9aced 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java @@ -5,8 +5,8 @@ public class LowercaseToStringSnapshotConfig extends PropertyResolvingSnapshotConfig { - @Override - public SnapshotSerializer getSerializer() { - return new LowercaseToStringSerializer(); - } + @Override + public SnapshotSerializer getSerializer() { + return new LowercaseToStringSerializer(); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java index 0c7d617..64782b6 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java @@ -3,28 +3,29 @@ import au.com.origin.snapshots.Expect; import au.com.origin.snapshots.annotations.SnapshotName; import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.util.HashMap; -import java.util.Map; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import java.util.HashMap; +import java.util.Map; + @ExtendWith({SnapshotExtension.class}) public class MyFirstSnapshotTest { - private Expect expect; + private Expect expect; - @SnapshotName("i_can_give_custom_names_to_my_snapshots") - @Test - public void toStringSerializationTest() { - expect.toMatchSnapshot("Hello World"); - } + @SnapshotName("i_can_give_custom_names_to_my_snapshots") + @Test + public void toStringSerializationTest() { + expect.toMatchSnapshot("Hello World"); + } - @Test - public void jsonSerializationTest() { - Map map = new HashMap<>(); - map.put("name", "John Doe"); - map.put("age", 40); + @Test + public void jsonSerializationTest() { + Map map = new HashMap<>(); + map.put("name", "John Doe"); + map.put("age", 40); - expect.serializer("json").toMatchSnapshot(map); - } + expect.serializer("json").toMatchSnapshot(map); + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java index bec56a7..f7a09ab 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java @@ -1,8 +1,8 @@ package au.com.origin.snapshots.docs; public class TestObject { - @Override - public String toString() { - return "This is a snapshot of the toString() method"; - } + @Override + public String toString() { + return "This is a snapshot of the toString() method"; + } } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java index 9760d3a..9ca5f08 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java @@ -6,13 +6,13 @@ import au.com.origin.snapshots.serializers.SnapshotSerializer; public class UppercaseToStringSerializer implements SnapshotSerializer { - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - return gen.toSnapshot(object.toString().toUpperCase()); - } + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + return gen.toSnapshot(object.toString().toUpperCase()); + } - @Override - public String getOutputFormat() { - return SerializerType.TEXT.name(); - } + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } } diff --git a/snapshot-testing-junit6/pom.xml b/snapshot-testing-junit6/pom.xml index da415ff..a9063e7 100644 --- a/snapshot-testing-junit6/pom.xml +++ b/snapshot-testing-junit6/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -12,7 +12,7 @@ snapshot-testing-junit6 finoid-snapshot-testing-junit6 - + 21 @@ -61,7 +61,7 @@ org.junit.jupiter junit-jupiter-api ${junit.version} - + org.junit.jupiter @@ -85,24 +85,24 @@ test - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + org.assertj @@ -112,12 +112,12 @@ - - - - - - + + + + + + com.fasterxml.jackson.core diff --git a/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java b/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java index 17f67be..d3e05b5 100644 --- a/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java +++ b/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java @@ -8,9 +8,7 @@ import au.com.origin.snapshots.exceptions.SnapshotMatchException; import au.com.origin.snapshots.logging.LoggingHelper; import au.com.origin.snapshots.utils.ReflectionUtils; -import java.lang.reflect.Field; import lombok.extern.slf4j.Slf4j; - import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; @@ -21,108 +19,109 @@ import org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor; import org.junit.jupiter.engine.descriptor.ClassTestDescriptor; +import java.lang.reflect.Field; + @Slf4j +@SuppressWarnings({"checkstyle:all", "EmptyBlockTag"}) // TODO (nw) rewrite public class SnapshotExtension implements AfterAllCallback, - BeforeAllCallback, - SnapshotConfigInjector, - ParameterResolver, - BeforeEachCallback { + BeforeAllCallback, + SnapshotConfigInjector, + ParameterResolver, + BeforeEachCallback { - private SnapshotVerifier snapshotVerifier; + private SnapshotVerifier snapshotVerifier; - @Override - public void beforeAll(ExtensionContext context) { - // don't fail if a test is run alone from the IDE for example - boolean failOnOrphans = shouldFailOnOrphans(context); - Class testClass = - context - .getTestClass() - .orElseThrow(() -> new SnapshotMatchException("Unable to locate Test class")); - this.snapshotVerifier = new SnapshotVerifier(getSnapshotConfig(), testClass, failOnOrphans); - } + @Override + public void beforeAll(ExtensionContext context) { + // don't fail if a test is run alone from the IDE for example + boolean failOnOrphans = shouldFailOnOrphans(context); + Class testClass = + context + .getTestClass() + .orElseThrow(() -> new SnapshotMatchException("Unable to locate Test class")); + this.snapshotVerifier = new SnapshotVerifier(getSnapshotConfig(), testClass, failOnOrphans); + } - @Override - public void afterAll(ExtensionContext context) { - this.snapshotVerifier.validateSnapshots(); - } + @Override + public void afterAll(ExtensionContext context) { + this.snapshotVerifier.validateSnapshots(); + } - @Override - public SnapshotConfig getSnapshotConfig() { - return new PropertyResolvingSnapshotConfig(); - } + @Override + public SnapshotConfig getSnapshotConfig() { + return new PropertyResolvingSnapshotConfig(); + } - /** - * FIXME This is a hack until I find the correct way to determine if a test run is individual or - * as part of a class - * - * @param context - * @return - */ - private boolean shouldFailOnOrphans(ExtensionContext context) { - try { - Field field = context.getClass().getSuperclass().getDeclaredField("testDescriptor"); - field.setAccessible(true); - Object testDescriptor = field.get(context); - if (testDescriptor instanceof ClassTestDescriptor) { // Junit 5.3.2 - ClassTestDescriptor classTestDescriptor = (ClassTestDescriptor) testDescriptor; - return classTestDescriptor.getChildren().size() > 1; - } else if (testDescriptor instanceof ClassBasedTestDescriptor) { // Junit 5.7.2 - ClassBasedTestDescriptor classTestDescriptor = (ClassBasedTestDescriptor) testDescriptor; - return classTestDescriptor.getChildren().size() > 1; - } - } catch (Exception e) { - log.error( - "FAILED: (Java Snapshot Testing) Unable to get JUnit5 ClassTestDescriptor or ClassBasedTestDescriptor!\n" - + "Ensure you are using Junit5 >= 5.3.2\n" - + "This may be due to JUnit5 changing their private api as we use reflection to access it\n" - + "Log a support ticket https://github.com/origin-energy/java-snapshot-testing/issues and supply your JUnit5 version\n" - + "Setting failOnOrphans=true as this is the safest option." - + "This means that running a test alone (say from the IDE) will fail the snapshot, you need to run the entire class.", - e); + /** + * FIXME This is a hack until I find the correct way to determine if a test run is individual or + * as part of a class + * + * @param context + * @return + */ + private boolean shouldFailOnOrphans(ExtensionContext context) { + try { + Field field = context.getClass().getSuperclass().getDeclaredField("testDescriptor"); + field.setAccessible(true); + Object testDescriptor = field.get(context); + if (testDescriptor instanceof ClassTestDescriptor classTestDescriptor) { // Junit 5.3.2 + return classTestDescriptor.getChildren().size() > 1; + } else if (testDescriptor instanceof ClassBasedTestDescriptor classTestDescriptor) { // Junit 5.7.2 + return classTestDescriptor.getChildren().size() > 1; + } + } catch (Exception e) { + log.error( + "FAILED: (Java Snapshot Testing) Unable to get JUnit5 ClassTestDescriptor or ClassBasedTestDescriptor!\n" + + "Ensure you are using Junit5 >= 5.3.2\n" + + "This may be due to JUnit5 changing their private api as we use reflection to access it\n" + + "Log a support ticket https://github.com/origin-energy/java-snapshot-testing/issues and supply your JUnit5 version\n" + + "Setting failOnOrphans=true as this is the safest option." + + "This means that running a test alone (say from the IDE) will fail the snapshot, you need to run the entire class.", + e); + } + return true; } - return true; - } - @Override - public boolean supportsParameter( - ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - boolean supports = parameterContext.getParameter().getType() == Expect.class; - if (supports) { - LoggingHelper.deprecatedV5( - log, - "Injecting 'Expect' via method a argument is no longer recommended. Consider using instance variable injection instead."); + @Override + public boolean supportsParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + boolean supports = parameterContext.getParameter().getType() == Expect.class; + if (supports) { + LoggingHelper.deprecatedV5( + log, + "Injecting 'Expect' via method a argument is no longer recommended. Consider using instance variable injection instead."); + } + return supports; } - return supports; - } - @Override - public Object resolveParameter( - ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - return new Expect( - snapshotVerifier, - extensionContext - .getTestMethod() - .orElseThrow(() -> new RuntimeException("getTestMethod() is missing"))); - } + @Override + public Object resolveParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) + throws ParameterResolutionException { + return new Expect( + snapshotVerifier, + extensionContext + .getTestMethod() + .orElseThrow(() -> new RuntimeException("getTestMethod() is missing"))); + } - @Override - public void beforeEach(ExtensionContext context) { - if (context.getTestInstance().isPresent() && context.getTestMethod().isPresent()) { - ReflectionUtils.findFieldByPredicate( - context.getTestClass().get(), (field) -> field.getType() == Expect.class) - .ifPresent( - (field) -> { - Expect expect = Expect.of(snapshotVerifier, context.getTestMethod().get()); - ReflectionUtils.makeAccessible(field); - try { - field.set(context.getTestInstance().get(), expect); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); + @Override + public void beforeEach(ExtensionContext context) { + if (context.getTestInstance().isPresent() && context.getTestMethod().isPresent()) { + ReflectionUtils.findFieldByPredicate( + context.getTestClass().get(), (field) -> field.getType() == Expect.class) + .ifPresent( + (field) -> { + Expect expect = Expect.of(snapshotVerifier, context.getTestMethod().get()); + ReflectionUtils.makeAccessible(field); + try { + field.set(context.getTestInstance().get(), expect); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + }); + } } - } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java index 8b89737..5647c54 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java @@ -8,17 +8,17 @@ @ExtendWith({SnapshotExtension.class}) public class BaseClassTest { - class TestBase { - Expect expect; - } + class TestBase { + Expect expect; + } - @Nested - @ExtendWith(SnapshotExtension.class) - class NestedClass extends TestBase { + @Nested + @ExtendWith(SnapshotExtension.class) + class NestedClass extends TestBase { - @Test - public void helloWorldTest() { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } } - } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java index 7267329..d770ee3 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java @@ -1,52 +1,54 @@ package au.com.origin.snapshots; -import static org.assertj.core.api.Assertions.assertThat; - import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; + +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite @ExtendWith({SnapshotExtension.class}) public class NestedClassTest { - @AfterAll - public static void afterAll() { - Path path = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest.snap"); - assertThat(Files.exists(path)).isFalse(); - } + @AfterAll + public static void afterAll() { + Path path = + Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest.snap"); + assertThat(Files.exists(path)).isFalse(); + } - @Nested - class NestedClassWithExpectArgument { + @Nested + class NestedClassWithExpectArgument { - @Test - public void helloWorldTest(Expect expect) { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest(Expect expect) { + expect.toMatchSnapshot("Hello World"); + } } - } - @Nested - class NestedClassWithoutSnapshot { + @Nested + class NestedClassWithoutSnapshot { - @Test - public void helloWorldTest() { - assertThat(true).isTrue(); + @Test + public void helloWorldTest() { + assertThat(true).isTrue(); + } } - } - @Nested - class NestedClassWithExpectInstance { + @Nested + class NestedClassWithExpectInstance { - Expect expect; + Expect expect; - @Test - public void helloWorldTest() { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } } - } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java index d4ac92c..87c85e9 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java @@ -1,35 +1,37 @@ package au.com.origin.snapshots; -import static org.assertj.core.api.Assertions.assertThat; - import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.assertj.core.api.Assertions.assertThat; + +@SuppressWarnings("checkstyle:all") // TODO (nw) rewrite public class NestedClassTestWithExtends { - @AfterAll - public static void afterAll() { - Path path = - Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); - assertThat(Files.exists(path)).isFalse(); - } + @AfterAll + public static void afterAll() { + Path path = + Paths.get( + "src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); + assertThat(Files.exists(path)).isFalse(); + } - @ExtendWith(SnapshotExtension.class) - @Nested - class NestedClass { + @ExtendWith(SnapshotExtension.class) + @Nested + class NestedClass { - Expect expect; + Expect expect; - @Test - public void helloWorldTest() { - expect.toMatchSnapshot("Hello World"); + @Test + public void helloWorldTest() { + expect.toMatchSnapshot("Hello World"); + } } - } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java index e1c4044..d8eb3ec 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java @@ -8,37 +8,37 @@ @ExtendWith(SnapshotExtension.class) public class SnapshotExtensionUsedTest { - private Expect expect; - - @Test - public void shouldUseExtension(Expect expect) { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void shouldUseExtensionAgain(Expect expect) { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void shouldUseExtensionViaInstanceVariable() { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void shouldUseExtensionAgainViaInstanceVariable() { - expect.toMatchSnapshot("Hello World"); - } - - @SnapshotName("hello_world") - @Test - public void snapshotWithName() { - expect.toMatchSnapshot("Hello World"); - } - - @SnapshotName("hello_world_2") - @Test - public void snapshotWithNameAgain() { - expect.toMatchSnapshot("Hello World"); - } + private Expect expect; + + @Test + public void shouldUseExtension(Expect expect) { + expect.toMatchSnapshot("Hello World"); + } + + @Test + public void shouldUseExtensionAgain(Expect expect) { + expect.toMatchSnapshot("Hello World"); + } + + @Test + public void shouldUseExtensionViaInstanceVariable() { + expect.toMatchSnapshot("Hello World"); + } + + @Test + public void shouldUseExtensionAgainViaInstanceVariable() { + expect.toMatchSnapshot("Hello World"); + } + + @SnapshotName("hello_world") + @Test + public void snapshotWithName() { + expect.toMatchSnapshot("Hello World"); + } + + @SnapshotName("hello_world_2") + @Test + public void snapshotWithNameAgain() { + expect.toMatchSnapshot("Hello World"); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java index 1f63e88..09729fb 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java @@ -2,50 +2,51 @@ import au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.util.stream.Stream; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import java.util.stream.Stream; + @ExtendWith({SnapshotExtension.class}) class SnapshotParameterTest { - private Expect expect; - - static Stream testData() { - - return Stream.of( - Arguments.of("Scenario2", "test input 1"), - Arguments.of("Scenario2", "test input 1"), - Arguments.of("Scenario2", "test input 1"), - Arguments.of("Scenario3", "test input 2"), - Arguments.of("Scenario3", "test input 2")); - } - - @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") - void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { - expect.toMatchSnapshot("Duplicates are OK"); - expect.toMatchSnapshot("Duplicates are OK"); - expect.scenario("Scenario1").toMatchSnapshot("Additional snapshots need to include a scenario"); - expect - .serializer(JacksonSnapshotSerializer.class) - .scenario(scenario) - .toMatchSnapshot(testInput); - } - - @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") - void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { - this.expect.toMatchSnapshot("Duplicates are OK"); - this.expect.toMatchSnapshot("Duplicates are OK"); - this.expect - .scenario("Scenario1") - .toMatchSnapshot("Additional snapshots need to include a scenario"); - this.expect - .serializer(JacksonSnapshotSerializer.class) - .scenario(scenario) - .toMatchSnapshot(testInput); - } + private Expect expect; + + static Stream testData() { + + return Stream.of( + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario2", "test input 1"), + Arguments.of("Scenario3", "test input 2"), + Arguments.of("Scenario3", "test input 2")); + } + + @ParameterizedTest + @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { + expect.toMatchSnapshot("Duplicates are OK"); + expect.toMatchSnapshot("Duplicates are OK"); + expect.scenario("Scenario1").toMatchSnapshot("Additional snapshots need to include a scenario"); + expect + .serializer(JacksonSnapshotSerializer.class) + .scenario(scenario) + .toMatchSnapshot(testInput); + } + + @ParameterizedTest + @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { + this.expect.toMatchSnapshot("Duplicates are OK"); + this.expect.toMatchSnapshot("Duplicates are OK"); + this.expect + .scenario("Scenario1") + .toMatchSnapshot("Additional snapshots need to include a scenario"); + this.expect + .serializer(JacksonSnapshotSerializer.class) + .scenario(scenario) + .toMatchSnapshot(testInput); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java index 841635c..19842d9 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java @@ -11,22 +11,22 @@ // Notice we aren't using any framework extensions public class CustomFrameworkExample { - private static SnapshotVerifier snapshotVerifier; + private static SnapshotVerifier snapshotVerifier; - @BeforeAll - static void beforeAll() { - snapshotVerifier = - new SnapshotVerifier(new PropertyResolvingSnapshotConfig(), CustomFrameworkExample.class); - } + @BeforeAll + static void beforeAll() { + snapshotVerifier = + new SnapshotVerifier(new PropertyResolvingSnapshotConfig(), CustomFrameworkExample.class); + } - @AfterAll - static void afterAll() { - snapshotVerifier.validateSnapshots(); - } + @AfterAll + static void afterAll() { + snapshotVerifier.validateSnapshots(); + } - @Test - void shouldMatchSnapshotOne(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Hello World"); - } + @Test + void shouldMatchSnapshotOne(TestInfo testInfo) { + Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); + expect.toMatchSnapshot("Hello World"); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java index 1f0fece..28ce52e 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java @@ -11,8 +11,8 @@ @UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) public class CustomSnapshotConfigExample { - @Test - public void myTest(Expect expect) { - expect.toMatchSnapshot("hello world"); - } + @Test + public void myTest(Expect expect) { + expect.toMatchSnapshot("hello world"); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java index 1fe4b8a..b2593ce 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java @@ -9,18 +9,18 @@ @ExtendWith({SnapshotExtension.class}) public class JUnit5Example { - // Option 1: inject Expect as an instance variable - private Expect expect; + // Option 1: inject Expect as an instance variable + private Expect expect; - @Test - public void myTest1() { - // Verify your snapshot - expect.toMatchSnapshot("Hello World"); - } + @Test + public void myTest1() { + // Verify your snapshot + expect.toMatchSnapshot("Hello World"); + } - // Option 2: inject Expect into the method signature - @Test - public void myTest2(Expect expect) { - expect.toMatchSnapshot("Hello World Again"); - } + // Option 2: inject Expect into the method signature + @Test + public void myTest2(Expect expect) { + expect.toMatchSnapshot("Hello World Again"); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java index eae0ab2..bd0be20 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java @@ -10,25 +10,25 @@ @UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) public class JUnit5ResolutionHierarchyExample { - private Expect expect; + private Expect expect; - @Test - public void aliasMethodTest() { - expect - .serializer("json") // <------ Using snapshot.properties - .toMatchSnapshot(new TestObject()); - } + @Test + public void aliasMethodTest() { + expect + .serializer("json") // <------ Using snapshot.properties + .toMatchSnapshot(new TestObject()); + } - @Test - public void customSerializerTest() { - expect - .serializer(UppercaseToStringSerializer.class) // <------ Using custom serializer - .toMatchSnapshot(new TestObject()); - } + @Test + public void customSerializerTest() { + expect + .serializer(UppercaseToStringSerializer.class) // <------ Using custom serializer + .toMatchSnapshot(new TestObject()); + } - // Read from LowercaseToStringSnapshotConfig defined on the class - @Test - public void lowercaseTest() { - expect.toMatchSnapshot(new TestObject()); - } + // Read from LowercaseToStringSnapshotConfig defined on the class + @Test + public void lowercaseTest() { + expect.toMatchSnapshot(new TestObject()); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java index d333eca..5c83846 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java @@ -6,13 +6,13 @@ import au.com.origin.snapshots.serializers.SnapshotSerializer; public class LowercaseToStringSerializer implements SnapshotSerializer { - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - return gen.toSnapshot(object.toString().toLowerCase()); - } + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + return gen.toSnapshot(object.toString().toLowerCase()); + } - @Override - public String getOutputFormat() { - return SerializerType.TEXT.name(); - } + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java index aac8eb5..8f9aced 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java @@ -5,8 +5,8 @@ public class LowercaseToStringSnapshotConfig extends PropertyResolvingSnapshotConfig { - @Override - public SnapshotSerializer getSerializer() { - return new LowercaseToStringSerializer(); - } + @Override + public SnapshotSerializer getSerializer() { + return new LowercaseToStringSerializer(); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java index 0c7d617..64782b6 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java @@ -3,28 +3,29 @@ import au.com.origin.snapshots.Expect; import au.com.origin.snapshots.annotations.SnapshotName; import au.com.origin.snapshots.junit5.SnapshotExtension; -import java.util.HashMap; -import java.util.Map; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import java.util.HashMap; +import java.util.Map; + @ExtendWith({SnapshotExtension.class}) public class MyFirstSnapshotTest { - private Expect expect; + private Expect expect; - @SnapshotName("i_can_give_custom_names_to_my_snapshots") - @Test - public void toStringSerializationTest() { - expect.toMatchSnapshot("Hello World"); - } + @SnapshotName("i_can_give_custom_names_to_my_snapshots") + @Test + public void toStringSerializationTest() { + expect.toMatchSnapshot("Hello World"); + } - @Test - public void jsonSerializationTest() { - Map map = new HashMap<>(); - map.put("name", "John Doe"); - map.put("age", 40); + @Test + public void jsonSerializationTest() { + Map map = new HashMap<>(); + map.put("name", "John Doe"); + map.put("age", 40); - expect.serializer("json").toMatchSnapshot(map); - } + expect.serializer("json").toMatchSnapshot(map); + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java index bec56a7..f7a09ab 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java @@ -1,8 +1,8 @@ package au.com.origin.snapshots.docs; public class TestObject { - @Override - public String toString() { - return "This is a snapshot of the toString() method"; - } + @Override + public String toString() { + return "This is a snapshot of the toString() method"; + } } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java index 9760d3a..9ca5f08 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java @@ -6,13 +6,13 @@ import au.com.origin.snapshots.serializers.SnapshotSerializer; public class UppercaseToStringSerializer implements SnapshotSerializer { - @Override - public Snapshot apply(Object object, SnapshotSerializerContext gen) { - return gen.toSnapshot(object.toString().toUpperCase()); - } + @Override + public Snapshot apply(Object object, SnapshotSerializerContext gen) { + return gen.toSnapshot(object.toString().toUpperCase()); + } - @Override - public String getOutputFormat() { - return SerializerType.TEXT.name(); - } + @Override + public String getOutputFormat() { + return SerializerType.TEXT.name(); + } } From dc35cd6067c518439dbebeca66451de2701ea8ee Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Sun, 25 Jan 2026 13:19:57 +0100 Subject: [PATCH 7/9] chore: improve pom.xml --- README.md | 809 +----------------- pom.xml | 103 +-- snapshot-testing-core/pom.xml | 71 +- snapshot-testing-jackson/pom.xml | 120 +-- snapshot-testing-jackson3/pom.xml | 119 +-- snapshot-testing-junit5/pom.xml | 99 +-- ...dClassTest$NestedClassWithoutSnapshot.snap | 3 + snapshot-testing-junit6/pom.xml | 103 +-- ...assTest$NestedClassWithExpectArgument.snap | 3 - ...dClassTest$NestedClassWithoutSnapshot.snap | 3 + 10 files changed, 162 insertions(+), 1271 deletions(-) create mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap create mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap diff --git a/README.md b/README.md index 28a4e54..ea15ef4 100644 --- a/README.md +++ b/README.md @@ -3,811 +3,4 @@ # Java Snapshot Testing - Inspired by [facebook's Jest framework](https://facebook.github.io/jest/docs/en/snapshot-testing.html) - -🎉 4.0.0 is out - -## Upgrading -- Upgrade guide from 3.X to 4.X [here](https://github.com/origin-energy/java-snapshot-testing/discussions/94) -- Upgrade guide from 2.X to 3.X [here](https://github.com/origin-energy/java-snapshot-testing/discussions/73) -- Upgrade guide from 2.X-BETA to 2.X [here](https://github.com/origin-energy/java-snapshot-testing/discussions/58) - -## The testing framework loved by ~~lazy~~ __productive__ devs - -- Tired of needing to `assertThat(foo).isEqualTo("bar")` again & again? -- Are you just wanting to ensure you don't break - for example - REST interfaces -- Are you manually saving text files for verification in your tests? - -**Want a better way?** -Then java-snapshot-testing might just be what you are looking for! - -## Quick Start (Junit5 + Gradle example) - -1. Add test dependencies - -```groovy -// In this case we are using the JUnit5 testing framework -testImplementation 'io.github.origin-energy:java-snapshot-testing-junit5:4.+' - -// slf4j logging implementation if you don't already have one -testImplementation("org.slf4j:slf4j-simple:2.0.0-alpha0") - -// Optional: Many will want to serialize into JSON. In this case you should also add the Jackson plugin -testImplementation 'io.github.origin-energy:java-snapshot-testing-plugin-jackson:4.+' -testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' -testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' - -// Optional: If you want Jackson to serialize Java 8 date/time types or Optionals you should also add the following dependencies -testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.20.1' -testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1' -``` - -2. Create `snapshot.properties` and configure your global settings. Be sure to set `output-dir` appropriately for your - JVM language. - -- /src/test/resources/snapshot.properties - - ```text -serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer -serializer.base64=au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer -serializer.json=au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer -serializer.orderedJson=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer -comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator -reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter -snapshot-dir=__snapshots__ -output-dir=src/test/java -ci-env-var=CI -update-snapshot=none -``` - -3. Enable snapshot testing and write your first test - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit5.SnapshotExtension; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import java.util.HashMap; -import java.util.Map; - -@ExtendWith({SnapshotExtension.class}) -public class MyFirstSnapshotTest { - - private Expect expect; - - @SnapshotName("i_can_give_custom_names_to_my_snapshots") - @Test - public void toStringSerializationTest() { - expect.toMatchSnapshot("Hello World"); - } - - @Test - public void jsonSerializationTest() { - Map map = new HashMap<>(); - map.put("name", "John Doe"); - map.put("age", 40); - - expect - .serializer("json") - .toMatchSnapshot(map); - } - -} -``` - -4. Run your test - -Bingo - you should now see your snapshot in the `__snapshots__` folder created next to your test. Try -changing `"Hello World"` to `"Hello Universe"` and watch it fail with a `.debug` file. - -```text -au.com.origin.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ - { - "age": 40, - "name": "John Doe" - } -] - - -i_can_give_custom_names_to_my_snapshots=[ -Hello World -] -``` - -## Advantages of Snapshot Testing - -- Great for testing JSON interfaces ensuring you don't break clients -- Fast and easy to test -- Will implicitly test areas of your code you did not think about -- Great of testing dynamic objects - -You're responsible for making sure your generated snapshots do not include platform specific or other non-deterministic -data. - -## Disadvantages of Snapshot Testing - -- You need to ensure your test is deterministic for all fields (there are ways to ignore things like dates) -- Does not give great insight to why the snapshot failed -- Can be difficult to troll though large snapshot changes where you might only be interested in a small set of fields - -## Installation [Maven](https://search.maven.org/search?q=java-snapshot-testing) - -These docs are for the latest `-SNAPSHOT` version published to maven central. Select the tag `X.X.X` matching your maven -dependency to get correct documentation for your version. - -Only if you want to integrate with an unsupported framework. [Show me how!](#using-an-unsupported-framework) - -- [Core](https://search.maven.org/search?q=a:java-snapshot-testing-core) - -We currently support: - -- [JUnit4](https://search.maven.org/search?q=a:java-snapshot-testing-junit4) -- [JUnit5](https://search.maven.org/search?q=a:java-snapshot-testing-junit5) -- [Spock](https://search.maven.org/search?q=a:java-snapshot-testing-spock) - -Plugins - -- [Jackson for JSON serialization](https://search.maven.org/search?q=a:java-snapshot-testing-plugin-jackson) - - You need jackson on your classpath (Gradle example) - ```groovy - // Required java-snapshot-testing peer dependencies - testImplementation 'com.fasterxml.jackson.core:jackson-core:2.20.1' - testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.20.1' - // Optional java-snapshot-testing peer dependencies - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.20.1' - testRuntimeOnly 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1' - ``` - -## How does it work? - -1. When a test runs for the first time, a `.snap` file is created in a `__snapshots__` sub-directory -1. On subsequent test runs, the `.snap` file is compared with the one produced by the test -1. If they don't match, the test fails and a `.snap.debug` with the conflict is created -1. It is then your job to decide if you have introduced a regression or intentionally changed the output (Use your IDE - file comparison tools to compare the two files or refer to the terminal output) -1. If you have introduced a regression you will need to fix your code -1. If you have intentionally changed the output you can manually modify the `.snap` file to make it pass or delete it - and it will be generated again from scratch -1. Once you fix the test, the `*.snap.debug` file will get deleted - -## What is a Snapshot? - -A text representation of your java object (toString() or JSON). - -**String snapshot example** - -```java -expect.toMatchSnapshot("Hello World"); -``` - -```text -au.com.example.company.HelloWorldTest.helloWorld=[ -Hello world -] -``` - -**JSON Snapshot Example** - -```java -expect.serializer("json").toMatchSnapshot(userDto); -``` - -```text -au.com.example.company.UserEndpointTest.shouldReturnCustomerData=[ - { - "id": "1", - "firstName": "John", - "lastName": "Smith", - "age": 34 - } -] -``` - -# Usage Examples - -All frameworks allow injection of the `Expect expect` via instance variable or method argument. In cases where -parameterised tests are used, it's often better to use an instance variable in order to avoid conflicts with -the underlying data table. - -Note: Due to the above restriction, method argument injection is destined for removal in future versions. - -## [JUnit 5](https://junit.org/junit5) - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.junit5.SnapshotExtension; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import au.com.origin.snapshots.Expect; - -// Ensure you extend your test class with the SnapshotExtension -@ExtendWith({SnapshotExtension.class}) -public class JUnit5Example { - - // Option 1: inject Expect as an instance variable - private Expect expect; - - @Test - public void myTest1() { - // Verify your snapshot - expect.toMatchSnapshot("Hello World"); - } - - // Option 2: inject Expect into the method signature - @Test - public void myTest2(Expect expect) { - expect.toMatchSnapshot("Hello World Again"); - } -} -``` - -## [JUnit 4](https://junit.org/junit4) - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit4.SnapshotRunner; -import au.com.origin.snapshots.Expect; -import org.junit.Test; -import org.junit.runner.RunWith; - -// Ensure you RunWith the SnapshotRunner -@RunWith(SnapshotRunner.class) -public class JUnit4Example { - - // Option 1: inject Expect as an instance variable - private Expect expect; - - @SnapshotName("my first test") - @Test - public void myTest1() { - // Verify your snapshot - expect.toMatchSnapshot("Hello World"); - } - - @SnapshotName("my second test") - @Test - // Option 2: inject Expect into the method signature - public void myTest2(Expect expect) { - expect.toMatchSnapshot("Hello World Again"); - } -} -``` - -In order to run alongside another JUnit4 test runner such as `@RunWith(Parameterized.class)`, you need to use the -Rule based configuration instead. - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit4.SnapshotClassRule; -import au.com.origin.snapshots.junit4.SnapshotRule; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; - -public class JUnit4RulesExample { - - @ClassRule - public static SnapshotClassRule snapshotClassRule = new SnapshotClassRule(); - - @Rule - public SnapshotRule snapshotRule = new SnapshotRule(snapshotClassRule); - - private Expect expect; - - @SnapshotName("my first test") - @Test - public void myTest1() { - expect.toMatchSnapshot("Hello World"); - } -} -``` - -See the [ParameterizedTest](https://github.com/origin-energy/java-snapshot-testing/blob/master/java-snapshot-testing-junit4/src/test/java/au/com/origin/snapshots/ParameterizedTest.java) for an example implementation - -## [Spock](http://spockframework.org/) - -```groovy -package au.com.origin.snapshots.docs - -import au.com.origin.snapshots.annotations.SnapshotName -import au.com.origin.snapshots.spock.EnableSnapshots -import spock.lang.Specification - -import au.com.origin.snapshots.Expect - -// Ensure you enable snapshot testing support -@EnableSnapshots -class SpockExample extends Specification { - - // Option 1: inject Expect as an instance variable - private Expect expect - - // With spock tests you should always use @SnapshotName - otherwise they become coupled to test order - @SnapshotName("should_use_extension") - def "Should use extension"() { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } - - @SnapshotName("should_use_extension_as_method_argument") - // Option 2: inject Expect into the method signature - def "Should use extension as method argument"(Expect expect) { - when: - expect.toMatchSnapshot("Hello World") - - then: - true - } -} -``` - -# Using an unsupported framework - -This library is in no way restricted to JUnit4, Junit5 or Spock. - -Any framework can support the library as long as it follows the following rules: - -1. Before all the tests in a single file execute (once only) - ```java - SnapshotVerifier snapshotVerifier = new SnapshotVerifier(new YourFrameworkSnapshotConfig(), testClass, failOnOrphans); - ``` -1. After all the tests in a single file execute (once only) - ```java - snapshotVerifier.validateSnapshots(); - ``` -1. For each test class, setup your expectations - ```java - Expect expect = Expect.of(snapshotVerifier, testMethod); - expect.toMatchSnapshot("Something"); - ``` - -Here is a JUnit5 example that does not use the JUnit5 extension - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; - -// Notice we aren't using any framework extensions -public class CustomFrameworkExample { - - private static SnapshotVerifier snapshotVerifier; - - @BeforeAll - static void beforeAll() { - snapshotVerifier = new SnapshotVerifier(new PropertyResolvingSnapshotConfig(), CustomFrameworkExample.class); - } - - @AfterAll - static void afterAll() { - snapshotVerifier.validateSnapshots(); - } - - @Test - void shouldMatchSnapshotOne(TestInfo testInfo) { - Expect expect = Expect.of(snapshotVerifier, testInfo.getTestMethod().get()); - expect.toMatchSnapshot("Hello World"); - } - -} -``` - -## Supplying your own snapshot name via @SnapshotName -By default, snapshots use the full method name as the identifier -For example -```text -au.com.origin.snapshots.docs.MyFirstSnapshotTest.helloWorldTest=[ -Hello World -] -``` - -This strategy has a number of problems -- it's long and unwieldy -- if the method name or class name changes, your tests become orphans -- The Spock framework tests use a generated method name that is based on index (Spock tests should always use `@SnapshotName`) - -You can supply a more meaningful name to your snapshot using `@SnapshotName("your_custom_name")` -This will generate as follows -``` -your_custom_name=[ -Hello World -] -``` - -Much more concise and not affected by class name or method name refactoring. - -## Resolving conflicting snapshot comparison via `*.snap.debug` - -Often your IDE has an excellent file comparison tool. - -- A `*.snap.debug` file will be created alongside your `*.snap` file when a conflict occurs. -- You can then use your IDE tooling to compare the two files. -- `*.snap.debug` is deleted automatically once the test passes. - -**Note:** `*.snap.debug` files should never be checked into version control so consider adding it to your `.gitignore` - -## snapshot.properties (required as of v2.4.0) - -This file allows you to conveniently setup global defaults - -| key | Description | -|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| -|serializer | Class name of the [serializer](#supplying-a-custom-snapshotserializer), default serializer | -|serializer.{name} | Class name of the [serializer](#supplying-a-custom-snapshotserializer), accessible via `.serializer("{name}")` | -|comparator | Class name of the [comparator](#supplying-a-custom-snapshotcomparator) | -|comparator.{name} | Class name of the [comparator](#supplying-a-custom-snapshotcomparator), accessible via `.comparator("{name}")` | -|reporters | Comma separated list of class names to use as [reporters](#supplying-a-custom-snapshotreporter) | -|reporters.{name} | Comma separated list of class names to use as [reporters](#supplying-a-custom-snapshotreporter), accessible via `.reporters("{name}")` | -|snapshot-dir | Name of sub-folder holding your snapshots | -|output-dir | Base directory of your test files (although it can be a different directory if you want) | -|ci-env-var | Name of environment variable used to detect if we are running on a Build Server | -|update-snapshot | Similar to `--updateSnapshot` in [Jest](https://jestjs.io/docs/en/snapshot-testing#updating-snapshots)
[all]=update all snapshots
[none]=update no snapshots
[MyTest1,MyTest2]=update snapshots in these classes only | - -For example: - - ```text -serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer -serializer.base64=au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer -serializer.json=au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer -serializer.orderedJson=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer -comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator -reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter -snapshot-dir=__snapshots__ -output-dir=src/test/java -ci-env-var=CI -update-snapshot=none -``` - -## Parameterized tests - -In cases where the same test runs multiple times with different parameters you need to set the `scenario` and it must be -unique for each run - -```java -expect.scenario(params).toMatchSnapshot("Something"); -``` - -## Scenario Example - -```groovy -package au.com.origin.snapshots.docs - -import au.com.origin.snapshots.Expect -import au.com.origin.snapshots.annotations.SnapshotName -import au.com.origin.snapshots.spock.EnableSnapshots -import spock.lang.Specification - -@EnableSnapshots -class SpockWithParametersExample extends Specification { - - private Expect expect - - @SnapshotName("convert_to_uppercase") - def 'Convert #scenario to uppercase'() { - when: 'I convert to uppercase' - String result = value.toUpperCase(); - then: 'Should convert letters to uppercase' - // Check you snapshot against your output using a unique scenario - expect.scenario(scenario).toMatchSnapshot(result) - where: - scenario | value - 'letter' | 'a' - 'number' | '1' - } -} -``` - -## Supplying a custom SnapshotSerializer - -The serializer determines how a class gets converted into a string. - -Serializers are pluggable, so you can write you own by implementing the `SnapshotSerializer` interface. - -Currently, we support the following serializers. - -### Shipped with core - -| Serializer | Description | -|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| -| ToStringSnapshotSerializer | uses the `toString()` method | -| Base64SnapshotSerializer | use for images or other binary sources that output a `byte[]`. The output is encoded to Base64 | - -### Shipped with Jackson plugin - -| Serializer | Description | -|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| -| JacksonSnapshotSerializer | uses [jackson](https://github.com/FasterXML/jackson) to convert a class to a snapshot | -| DeterministicJacksonSnapshotSerializer | extension of JacksonSnapshotSerializer that also orders Collections for situations where the order changes on multiple runs | - -Serializers are resolved in the following order. - -- (method level) explicitly `expect.serializer(ToStringSerializer.class).toMatchSnapshot(...);` or via property - file `expect.serializer("json").toMatchSnapshot(...);` -- (class level) explicitly `@UseSnapshotConfig` which gets read from the `getSerializer()` method -- (properties) implicitly via `snapshot.properties` - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.junit5.SnapshotExtension; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -@ExtendWith(SnapshotExtension.class) -@UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) -public class JUnit5ResolutionHierarchyExample { - - private Expect expect; - - @Test - public void aliasMethodTest() { - expect - .serializer("json") // <------ Using snapshot.properties - .toMatchSnapshot(new TestObject()); - } - - @Test - public void customSerializerTest() { - expect - .serializer(UppercaseToStringSerializer.class) // <------ Using custom serializer - .toMatchSnapshot(new TestObject()); - } - - // Read from LowercaseToStringSnapshotConfig defined on the class - @Test - public void lowercaseTest() { - expect.toMatchSnapshot(new TestObject()); - } -} -``` - -### Example: HibernateSerializer - -Sometimes the default serialization doesn't work for you. An example is Hibernate serialization where you get infinite -recursion on Lists/Sets. - -You can supply any serializer you like Gson, Jackson or something else. - -For example, the following will exclude the rendering of Lists without changing the source code to include `@JsonIgnore` -. This is good because you shouldn't need to add annotations to your source code for testing purposes only. - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreType; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.time.Instant; -import java.util.List; -import java.util.Set; - -public class HibernateSnapshotSerializer extends DeterministicJacksonSnapshotSerializer { - - @Override - public void configure(ObjectMapper objectMapper) { - super.configure(objectMapper); - - // Ignore Hibernate Lists to prevent infinite recursion - objectMapper.addMixIn(List.class, IgnoreTypeMixin.class); - objectMapper.addMixIn(Set.class, IgnoreTypeMixin.class); - - // Ignore Fields that Hibernate generates for us automatically - objectMapper.addMixIn(BaseEntity.class, IgnoreHibernateEntityFields.class); - } - - @JsonIgnoreType - class IgnoreTypeMixin { - } - - abstract class IgnoreHibernateEntityFields { - @JsonIgnore - abstract Long getId(); - - @JsonIgnore - abstract Instant getCreatedDate(); - - @JsonIgnore - abstract Instant getLastModifiedDate(); - } -} -``` - -## Supplying a custom SnapshotComparator - -The comparator determines if two snapshots match. - -Currently, we support one default comparator (`PlainTextEqualsComparator`) which uses string equals for comparison. - -This should work for most cases. Custom implementations of `SnapshotComparator` can provide more advanced comparisons. - -Comparators follow the same resolution order as Serializers - -1. method -1. class -1. snapshot.properties - -### Example: JsonObjectComparator - -The default comparator may be too strict for certain types of data. For example, when comparing json objects, formatting -of the json string or the order of fields may not be of much importance during comparison. A custom comparator can help -in such cases. - -For example, the following will convert a json string to a Map and then perform an equals comparison so that formatting -and field order are ignored. - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.SneakyThrows; - -public class JsonObjectComparator implements SnapshotComparator { - @Override - public boolean matches(Snapshot previous, Snapshot current) { - return asObject(previous.getName(), previous.getBody()).equals(asObject(current.getName(), current.getBody())); - } - - @SneakyThrows - private static Object asObject(String snapshotName, String json) { - return new ObjectMapper().readValue(json.replaceFirst(snapshotName + "=", ""), Object.class); - } -} -``` - -## Supplying a custom SnapshotReporter - -The reporter reports the details of comparison failures. - -Currently, we support one default reporter (`PlainTextSnapshotReporter`) which uses assertj's DiffUtils to generate a -patch of the differences between two snapshots. - -Custom reporters can be plugged in by implementing `SnapshotReporter`. - -Reporters follow the same resolution order as Serializers and Comparators - -### Example: JsonDiffReporter - -For generating and reporting json diffs using other libraries like https://github.com/skyscreamer/JSONassert -a custom reporter can be created like the one below. - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SerializerType; -import lombok.SneakyThrows; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; - -public class JsonAssertReporter implements SnapshotReporter { - @Override - public boolean supportsFormat(String outputFormat) { - return SerializerType.JSON.name().equalsIgnoreCase(outputFormat); - } - - @Override - @SneakyThrows - public void report(Snapshot previous, Snapshot current) { - JSONAssert.assertEquals(previous.getBody(), current.getBody(), JSONCompareMode.STRICT); - } -} -``` - -## Snapshot Headers -You can add metadata to your snapshots via headers. Headers can be used by Serializers, Comparators & Reporters -to help interrogate the snapshot. - -Custom Serializers can also inject default headers as needed. - -Example of injecting a header manually -```java -String obj = "hello" -expect - .header("className", obj.getClass().getName()) - .header("foo", "bar") - .toMatchSnapshot(obj); -``` - -Snapshot output -```text -au.com.origin.snapshots.SnapshotHeaders.canAddHeaders={ - "className": "java.lang.String", - "foo": "bar" -}[ -hello -] -``` - -## Supplying a custom SnapshotConfig - -You can override the snapshot configuration easily using the `@UseSnapshotConfig` annotation - -**JUnit5 Example** - -```java -package au.com.origin.snapshots.docs; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.junit5.SnapshotExtension; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -@ExtendWith(SnapshotExtension.class) -@UseSnapshotConfig(LowercaseToStringSnapshotConfig.class) -public class JUnit5ResolutionHierarchyExample { - - private Expect expect; - - @Test - public void aliasMethodTest() { - expect - .serializer("json") // <------ Using snapshot.properties - .toMatchSnapshot(new TestObject()); - } - - @Test - public void customSerializerTest() { - expect - .serializer(UppercaseToStringSerializer.class) // <------ Using custom serializer - .toMatchSnapshot(new TestObject()); - } - - // Read from LowercaseToStringSnapshotConfig defined on the class - @Test - public void lowercaseTest() { - expect.toMatchSnapshot(new TestObject()); - } -} -``` - -# Troubleshooting - -**I'm seeing this error in my logs** - -``` -org/slf4j/LoggerFactory -java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory -``` - -Solution: -Add an SLF4J Provider such as`testImplementation("org.slf4j:slf4j-simple:2.0.0-alpha0")` - -**My test source files are not in `src/test/java`** - -Solution: Override `output-dir` in `snapshot.properties` - -**I see the following error in JSON snapshots `java.lang.NoSuchFieldError: BINARY`** - -Solution: This happened to me in a spring-boot app, I removed my jackson dependencies and relied on the ones from -spring-boot instead. - -# Contributing - -see `CONTRIBUTING.md` +- Fork of https://github.com/origin-energy/java-snapshot-testing diff --git a/pom.xml b/pom.xml index 9553c5a..886cb2d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,9 +14,7 @@ snapshot-testing-parent ${revision} finoid-snapshot-testing-parent - A Java library designed to streamline testing by integrating Testcontainers, data fakers, test - fixtures, snapshot testing. - + A Java library designed to streamline testing by snapshot testing. pom @@ -26,20 +24,21 @@ 21 UTF-8 - - 3.51.1 - - 1.7.3 - 1.0.0 - 1.18.42 - 0.10.0 - - + 3.11.1 + 3.51.1 0.12.8 true + 1.7.3 + 2.20.1 + 3.0.3 + 1.0.0 + 5.12.2 + 6.0.2 + 1.18.42 + 2.0.17 @@ -52,15 +51,6 @@ - - - - - - - - - io.github.finoid snapshot-testing-core @@ -81,33 +71,11 @@ snapshot-testing-junit5 ${revision} - - - - - - - - - - - - - - - - - - - - - - - - - - - + + io.github.finoid + snapshot-testing-junit6 + ${revision} + org.checkerframework checker-qual @@ -117,32 +85,11 @@ - - - - - - - - - - - - - - - - - org.jspecify jspecify ${jspecify.version} - - - - org.projectlombok lombok @@ -168,17 +115,16 @@ - https://github.com/finoid/testify - scm:git:https://github.com/finoid/testify.git - scm:git:ssh://git@github.com/finoid/testify.git + https://github.com/finoid/snapshot-testing + scm:git:https://github.com/finoid/snapshot-testing.git + scm:git:ssh://git@github.com/finoid/snapshot-testing.git HEAD - https://github.com/finoid/testify + https://github.com/finoid/snapshot-testing - io.github.finoid codequality-maven-plugin @@ -224,7 +170,6 @@ - org.apache.maven.plugins maven-enforcer-plugin @@ -235,20 +180,12 @@ enforce - true true module-info - - org/jspecify/annotations/NullMarked - org/jspecify/annotations/NullUnmarked - org/jspecify/annotations/Nullable - org/jspecify/annotations/NonNull - org/jspecify/annotations/NonNull - true diff --git a/snapshot-testing-core/pom.xml b/snapshot-testing-core/pom.xml index fe6dbfe..d500061 100644 --- a/snapshot-testing-core/pom.xml +++ b/snapshot-testing-core/pom.xml @@ -20,95 +20,72 @@ 21 21 UTF-8 + + 2.21.0 + 5.21.0
- org.checkerframework - checker-qual + org.assertj + assertj-core + ${assertj.version} - - - com.fasterxml.jackson.core - jackson-core - 2.20.1 - provided + org.checkerframework + checker-qual - - com.fasterxml.jackson.core - jackson-databind - 2.20.1 - provided + org.opentest4j + opentest4j + 1.3.0 - org.slf4j slf4j-api - 2.0.17 + ${slf4j.version} + provided - org.slf4j - slf4j-simple - 2.0.17 + commons-io + commons-io + ${commons-io.version} test - - - - org.assertj - assertj-core - 3.11.1 - - - - org.opentest4j - opentest4j - 1.3.0 - - - org.mockito mockito-junit-jupiter - 2.23.0 + ${mockito.version} test - org.mockito mockito-core - 2.23.4 + ${mockito.version} test - org.junit.jupiter junit-jupiter-api - 5.3.2 - test + ${junit5.version} - org.junit.jupiter junit-jupiter-engine - 5.3.2 + ${junit5.version} test - org.junit.jupiter junit-jupiter-params - 5.3.2 + ${junit5.version} test - - commons-io - commons-io - 2.6 + org.slf4j + slf4j-simple + ${slf4j.version} test diff --git a/snapshot-testing-jackson/pom.xml b/snapshot-testing-jackson/pom.xml index e9d5774..dab2984 100644 --- a/snapshot-testing-jackson/pom.xml +++ b/snapshot-testing-jackson/pom.xml @@ -12,7 +12,7 @@ snapshot-testing-jackson finoid-snapshot-testing-jackson - + Jackson2 library for snapshot-testing 21 @@ -20,11 +20,7 @@ 21 21 UTF-8 - - 5.7.2 - 2.20.1 - 3.11.1 - 2.0.0-alpha0 + 1.5.3 @@ -32,134 +28,76 @@ org.checkerframework checker-qual - - com.fasterxml.jackson.core jackson-core - 2.20.1 + ${jackson2.version} + provided com.fasterxml.jackson.core jackson-databind - 2.20.1 + ${jackson2.version} + provided - com.fasterxml.jackson.datatype jackson-datatype-jdk8 - 2.20.1 + ${jackson2.version} + provided - com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.20.1 + ${jackson2.version} + provided + + + io.github.finoid + snapshot-testing-core - - org.slf4j slf4j-api - 2.0.17 + ${slf4j.version} + - org.slf4j - slf4j-simple - 2.0.17 + org.assertj + assertj-core + ${assertj.version} test - - - - io.github.finoid - snapshot-testing-core - - - org.junit.jupiter junit-jupiter-api - ${junit.version} - + ${junit5.version} + test org.junit.jupiter junit-jupiter-engine - ${junit.version} - provided - - - - - org.slf4j - slf4j-simple - ${slf4j.simple.version} + ${junit5.version} test - org.junit.jupiter junit-jupiter-params - ${junit.version} + ${junit5.version} test - - - - - - - - - - - - - - - - - - - - - org.assertj - assertj-core - ${assertj.version} + org.skyscreamer + jsonassert + ${jsonassert.version} test - - - - - - - - - - - - - - - - - - - - - - - - org.skyscreamer - jsonassert - 1.5.1 + org.slf4j + slf4j-simple + ${slf4j.version} test -
\ No newline at end of file diff --git a/snapshot-testing-jackson3/pom.xml b/snapshot-testing-jackson3/pom.xml index 9ee6af6..2363ffe 100644 --- a/snapshot-testing-jackson3/pom.xml +++ b/snapshot-testing-jackson3/pom.xml @@ -12,7 +12,7 @@ snapshot-testing-jackson3 finoid-snapshot-testing-jackson3 - + Jackson3 library for snapshot-testing 21 @@ -21,10 +21,9 @@ 21 UTF-8 - 5.7.2 - 2.20.1 3.11.1 - 2.0.0-alpha0 + 6.0.2 + 1.5.3 @@ -32,122 +31,64 @@ org.checkerframework checker-qual - - + + io.github.finoid + snapshot-testing-core + + + org.slf4j + slf4j-api + ${slf4j.version} + tools.jackson.core jackson-core - 3.0.3 + ${jackson3.version} + provided tools.jackson.core jackson-databind - 3.0.3 - - - - - org.slf4j - slf4j-api - 2.0.17 + ${jackson3.version} + provided + - org.slf4j - slf4j-simple - 2.0.17 + org.assertj + assertj-core + ${assertj.version} test - - - - io.github.finoid - snapshot-testing-core - - - org.junit.jupiter junit-jupiter-api - ${junit.version} - + ${junit6.version} + test org.junit.jupiter junit-jupiter-engine - ${junit.version} - provided - - - - - org.slf4j - slf4j-simple - ${slf4j.simple.version} + ${junit6.version} test - org.junit.jupiter junit-jupiter-params - ${junit.version} + ${junit6.version} test - - - - - - - - - - - - - - - - - - - - - org.assertj - assertj-core - ${assertj.version} + org.skyscreamer + jsonassert + ${jsonassert.version} test - - - - - - - - - - - - - - - - - - - - - - - - org.skyscreamer - jsonassert - 1.5.1 + org.slf4j + slf4j-simple + ${slf4j.version} test - \ No newline at end of file diff --git a/snapshot-testing-junit5/pom.xml b/snapshot-testing-junit5/pom.xml index ffce497..a4caa29 100644 --- a/snapshot-testing-junit5/pom.xml +++ b/snapshot-testing-junit5/pom.xml @@ -12,7 +12,7 @@ snapshot-testing-junit5 finoid-snapshot-testing-junit5 - + JUnit5 library for snapshot-testing 21 @@ -20,33 +20,9 @@ 21 21 UTF-8 - - 5.7.2 - 2.20.1 - 3.11.1 - 2.0.0-alpha0 - - org.checkerframework - checker-qual - - - - org.slf4j - slf4j-api - 2.0.17 - - - - org.slf4j - slf4j-simple - 2.0.17 - test - - - io.github.finoid snapshot-testing-core @@ -55,83 +31,58 @@ io.github.finoid snapshot-testing-jackson - - + + org.checkerframework + checker-qual + org.junit.jupiter junit-jupiter-api - ${junit.version} - + ${junit5.version} + provided org.junit.jupiter junit-jupiter-engine - ${junit.version} + ${junit5.version} provided + + org.slf4j + slf4j-api + ${slf4j.version} + - org.slf4j - slf4j-simple - ${slf4j.simple.version} + com.fasterxml.jackson.core + jackson-core + ${jackson2.version} test - - org.junit.jupiter - junit-jupiter-params - ${junit.version} + com.fasterxml.jackson.core + jackson-databind + ${jackson2.version} test - - - - - - - - - - - - - - - - - - - - org.assertj assertj-core ${assertj.version} test - - - - - - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} + org.junit.jupiter + junit-jupiter-params + ${junit5.version} test - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} + org.slf4j + slf4j-simple + ${slf4j.version} test - - \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap new file mode 100644 index 0000000..b8d8953 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap @@ -0,0 +1,3 @@ +au.com.origin.snapshots.NestedClassTest$NestedClassWithoutSnapshot.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/pom.xml b/snapshot-testing-junit6/pom.xml index a9063e7..1185d31 100644 --- a/snapshot-testing-junit6/pom.xml +++ b/snapshot-testing-junit6/pom.xml @@ -12,7 +12,7 @@ snapshot-testing-junit6 finoid-snapshot-testing-junit6 - + JUnit5 library for snapshot-testing 21 @@ -20,33 +20,9 @@ 21 21 UTF-8 - - 6.0.2 - 2.20.1 - 3.11.1 - 2.0.0-alpha0 - - org.checkerframework - checker-qual - - - - org.slf4j - slf4j-api - 2.0.17 - - - - org.slf4j - slf4j-simple - 2.0.17 - test - - - io.github.finoid snapshot-testing-core @@ -55,83 +31,58 @@ io.github.finoid snapshot-testing-jackson3 - - + + org.checkerframework + checker-qual + org.junit.jupiter junit-jupiter-api - ${junit.version} - + ${junit6.version} + provided org.junit.jupiter junit-jupiter-engine - ${junit.version} + ${junit6.version} provided - - org.slf4j - slf4j-simple - ${slf4j.simple.version} - test + slf4j-api + ${slf4j.version} + - org.junit.jupiter - junit-jupiter-params - ${junit.version} - test + tools.jackson.core + jackson-core + ${jackson3.version} + provided + + + tools.jackson.core + jackson-databind + ${jackson3.version} + provided - - - - - - - - - - - - - - - - - - - - org.assertj assertj-core ${assertj.version} test - - - - - - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} + org.junit.jupiter + junit-jupiter-params + ${junit6.version} test - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} + org.slf4j + slf4j-simple + ${slf4j.version} test - - \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap deleted file mode 100644 index e70d0b5..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTest$NestedClassWithExpectArgument.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap new file mode 100644 index 0000000..b8d8953 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap @@ -0,0 +1,3 @@ +au.com.origin.snapshots.NestedClassTest$NestedClassWithoutSnapshot.helloWorldTest=[ +Hello World +] \ No newline at end of file From 7d51318c591bb2effd6e04ae47d07501d43ad556 Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Sun, 25 Jan 2026 13:25:47 +0100 Subject: [PATCH 8/9] chore: rename snapshot-testing-jackson module to snapshot-testing-jackson2 --- README.md | 6 +- pom.xml | 4 +- snapshot-testing-core/.gitignore | 2 +- .../PlainTextEqualsComparator.java | 17 -- .../reporters/PlainTextSnapshotReporter.java | 17 -- .../github/finoid}/snapshots/Expect.java | 17 +- .../github/finoid}/snapshots/Snapshot.java | 4 +- .../finoid}/snapshots/SnapshotContext.java | 22 +- .../finoid}/snapshots/SnapshotFile.java | 2 +- .../finoid}/snapshots/SnapshotHeader.java | 2 +- .../finoid}/snapshots/SnapshotProperties.java | 4 +- .../snapshots/SnapshotSerializerContext.java | 4 +- .../finoid}/snapshots/SnapshotVerifier.java | 13 +- .../snapshots/annotations/SnapshotName.java | 2 +- .../annotations/UseSnapshotConfig.java | 4 +- .../PlainTextEqualsComparator.java | 17 ++ .../comparators/SnapshotComparator.java | 4 +- .../v1/PlainTextEqualsComparator.java | 6 +- .../PropertyResolvingSnapshotConfig.java | 14 +- .../snapshots/config/SnapshotConfig.java | 8 +- .../config/SnapshotConfigInjector.java | 2 +- .../exceptions/LogGithubIssueException.java | 2 +- ...MissingSnapshotPropertiesKeyException.java | 2 +- .../exceptions/ReservedWordException.java | 2 +- .../SnapshotExtensionException.java | 2 +- .../exceptions/SnapshotMatchException.java | 2 +- .../snapshots/logging/LoggingHelper.java | 2 +- .../reporters/PlainTextSnapshotReporter.java | 17 ++ .../snapshots/reporters/SnapshotReporter.java | 4 +- .../v1/PlainTextSnapshotReporter.java | 6 +- .../serializers/Base64SnapshotSerializer.java | 8 +- .../snapshots/serializers/SerializerType.java | 2 +- .../serializers/SnapshotSerializer.java | 6 +- .../ToStringSnapshotSerializer.java | 8 +- .../v1/Base64SnapshotSerializer.java | 10 +- .../v1/ToStringSnapshotSerializer.java | 12 +- .../snapshots/utils/ReflectionUtils.java | 2 +- .../origin/snapshots/NoNameChangeTest.java | 40 --- .../DebugSnapshotLineEndingsTest.snap | 4 - .../__snapshots__/DebugSnapshotTest.snap | 13 - .../EqualDebugSnapshotFileTest.snap | 13 - .../PrivateCalledMethodTest.snap | 3 - .../__snapshots__/ScenarioTest.snap | 28 -- .../__snapshots__/SnapshotHeaders.snap | 10 - .../SnapshotIntegrationTest.snap | 37 --- .../SnapshotOverrideClassTest.snap | 3 - .../UpdateSnapshotPropertyTest.snap | 8 - .../__snapshots__/UseCustomConfigTest.snap | 4 - .../UseCustomSerializerTest.snap | 10 - .../snapshots/CustomFolderSnapshotTest.java | 6 +- .../DebugSnapshotLineEndingsTest.java | 16 +- .../finoid}/snapshots/DebugSnapshotTest.java | 16 +- .../snapshots/EmptySnapshotFileTest.java | 12 +- .../snapshots/EqualDebugSnapshotFileTest.java | 8 +- .../github/finoid}/snapshots/FakeObject.java | 2 +- .../finoid/snapshots/NoNameChangeTest.java | 40 +++ .../snapshots/OnLoadSnapshotFileTest.java | 14 +- .../finoid}/snapshots/OrphanSnapshotTest.java | 12 +- .../snapshots/PrivateCalledMethodTest.java | 4 +- .../snapshots/ReflectionUtilities.java | 4 +- .../finoid}/snapshots/ScenarioTest.java | 8 +- .../finoid}/snapshots/SnapshotCaptor.java | 4 +- .../snapshots/SnapshotContextTest.java | 12 +- .../finoid}/snapshots/SnapshotHeaders.java | 10 +- .../snapshots/SnapshotIntegrationTest.java | 12 +- .../SnapshotMatcherScenarioTest.java | 10 +- .../snapshots/SnapshotMatcherTest.java | 10 +- .../snapshots/SnapshotNameAnnotationTest.java | 8 +- ...pshotNameAnnotationWithDuplicatesTest.java | 10 +- .../snapshots/SnapshotOverrideClassTest.java | 4 +- .../snapshots/SnapshotSuperClassTest.java | 2 +- .../finoid}/snapshots/SnapshotTest.java | 32 +- .../finoid}/snapshots/SnapshotUtils.java | 8 +- .../finoid}/snapshots/SnapshotUtilsTest.java | 6 +- .../snapshots/UpdateSnapshotPropertyTest.java | 22 +- .../finoid}/snapshots/UpdateSnapshotTest.java | 32 +- .../snapshots/UseCustomConfigTest.java | 10 +- .../snapshots/UseCustomSerializerTest.java | 8 +- .../PlainTextEqualsComparatorTest.java | 4 +- .../snapshots/config/BaseSnapshotConfig.java | 16 +- .../config/ToStringSnapshotConfig.java | 10 +- .../DebugSnapshotLineEndingsTest.snap | 4 + .../__snapshots__/DebugSnapshotTest.snap | 13 + .../EmptySnapshotFileTest$NestedClass.snap | 0 .../__snapshots__/EmptySnapshotFileTest.snap | 0 .../EqualDebugSnapshotFileTest.snap | 13 + .../__snapshots__/OrphanSnapshotTest.snap | 2 +- .../PrivateCalledMethodTest.snap | 3 + .../__snapshots__/README.md | 0 .../__snapshots__/ScenarioTest.snap | 28 ++ .../__snapshots__/SnapshotHeaders.snap | 10 + .../SnapshotIntegrationTest.snap | 37 +++ .../SnapshotNameAnnotationTest.snap | 0 .../SnapshotOverrideClassTest.snap | 3 + .../__snapshots__/SnapshotUtilsTest.snap | 0 .../UpdateSnapshotPropertyTest.snap | 8 + .../__snapshots__/UseCustomConfigTest.snap | 4 + .../UseCustomSerializerTest.snap | 10 + .../PlainTextSnapshotReporterTest.java | 6 +- .../Base64SnapshotSerializerTest.java | 8 +- .../LowercaseToStringSerializer.java | 6 +- .../ToStringSnapshotSerializerTest.java | 8 +- .../UppercaseToStringSerializer.java | 6 +- .../src/test/resources/snapshot.properties | 2 +- .../JacksonSnapshotSerializer.java | 17 -- .../__snapshots__/CustomSerializerTest.snap | 5 - ...ministicJacksonSnapshotSerializerTest.snap | 140 --------- .../JacksonSnapshotSerializerTest.snap | 140 --------- .../src/test/resources/snapshot.properties | 8 - .../pom.xml | 4 +- .../DeterministicCollectionModule.java | 2 +- ...eterministicJacksonSnapshotSerializer.java | 8 +- .../JacksonSnapshotSerializer.java | 17 ++ ...eterministicJacksonSnapshotSerializer.java | 4 +- .../v1/JacksonSnapshotSerializer.java | 12 +- .../serializers/v1/SnapshotPrettyPrinter.java | 2 +- .../snapshots/jackson/NoNameChangeTest.java | 10 +- .../jackson}/ReflectionUtilities.java | 4 +- .../snapshots/jackson/docs/BaseEntity.java | 2 +- .../jackson/docs/CustomSerializerTest.java | 8 +- .../docs/HibernateSnapshotSerializer.java | 4 +- .../jackson/docs/JsonAssertReporter.java | 8 +- .../jackson/docs/JsonObjectComparator.java | 6 +- .../__snapshots__/CustomSerializerTest.snap | 12 + ...ministicJacksonSnapshotSerializerTest.java | 10 +- .../JacksonSnapshotSerializerTest.java | 22 +- ...ministicJacksonSnapshotSerializerTest.snap | 282 ++++++++++++++++++ .../JacksonSnapshotSerializerTest.snap | 282 ++++++++++++++++++ .../src/test/resources/snapshot.properties | 8 + .../v1/DeterministicCollectionModule.java | 2 +- ...eterministicJacksonSnapshotSerializer.java | 2 +- .../v1/JacksonSnapshotSerializer.java | 12 +- .../__snapshots__/CustomSerializerTest.snap | 5 - ...ministicJacksonSnapshotSerializerTest.snap | 140 --------- .../JacksonSnapshotSerializerTest.snap | 140 --------- .../snapshots/jackson3/NoNameChangeTest.java | 10 +- .../jackson3}/ReflectionUtilities.java | 4 +- .../snapshots/jackson3/docs/BaseEntity.java | 2 +- .../jackson3/docs/CustomSerializerTest.java | 8 +- .../docs/HibernateSnapshotSerializer.java | 4 +- .../jackson3/docs/JsonAssertReporter.java | 8 +- .../jackson3/docs/JsonObjectComparator.java | 6 +- .../__snapshots__/CustomSerializerTest.snap | 12 + ...ministicJacksonSnapshotSerializerTest.java | 10 +- .../v1/JacksonSnapshotSerializerTest.java | 22 +- ...ministicJacksonSnapshotSerializerTest.snap | 282 ++++++++++++++++++ .../JacksonSnapshotSerializerTest.snap | 282 ++++++++++++++++++ .../src/test/resources/snapshot.properties | 8 +- snapshot-testing-junit5/pom.xml | 2 +- .../snapshots/junit5/SnapshotExtension.java | 20 +- .../BaseClassTest$NestedClass.snap | 3 - ...dClassTest$NestedClassWithoutSnapshot.snap | 3 - ...estedClassTestWithExtends$NestedClass.snap | 3 - .../SnapshotExtensionUsedTest.snap | 28 -- .../__snapshots__/SnapshotParameterTest.snap | 38 --- .../__snapshots__/CustomFrameworkExample.snap | 3 - .../CustomSnapshotConfigExample.snap | 1 - .../CustomSnapshotContextConfigExample.snap | 1 - .../docs/__snapshots__/JUnit5Example.snap | 8 - .../JUnit5ResolutionHierarchyExample.snap | 9 - .../MyFirstSnapshotContextTest.snap | 11 - .../finoid}/snapshots/BaseClassTest.java | 4 +- .../finoid}/snapshots/NestedClassTest.java | 6 +- .../snapshots/NestedClassTestWithExtends.java | 6 +- .../snapshots/SnapshotExtensionUsedTest.java | 6 +- .../snapshots/SnapshotParameterTest.java | 10 +- .../BaseClassTest$NestedClass.snap | 3 + ...assTest$NestedClassWithExpectInstance.snap | 3 + ...dClassTest$NestedClassWithoutSnapshot.snap | 3 + ...estedClassTestWithExtends$NestedClass.snap | 3 + .../SnapshotExtensionUsedTest.snap | 28 ++ .../__snapshots__/SnapshotParameterTest.snap | 38 +++ .../docs/CustomFrameworkExample.java | 8 +- .../docs/CustomSnapshotConfigExample.java | 8 +- .../finoid}/snapshots/docs/JUnit5Example.java | 6 +- .../JUnit5ResolutionHierarchyExample.java | 8 +- .../docs/LowercaseToStringSerializer.java | 10 +- .../docs/LowercaseToStringSnapshotConfig.java | 6 +- .../snapshots/docs/MyFirstSnapshotTest.java | 8 +- .../finoid}/snapshots/docs/TestObject.java | 2 +- .../docs/UppercaseToStringSerializer.java | 10 +- .../__snapshots__/CustomFrameworkExample.snap | 3 + .../CustomSnapshotConfigExample.snap | 1 + .../CustomSnapshotContextConfigExample.snap | 0 .../docs/__snapshots__/JUnit5Example.snap | 8 + .../JUnit5ResolutionHierarchyExample.snap | 9 + .../MyFirstSnapshotContextTest.snap | 0 .../__snapshots__/MyFirstSnapshotTest.snap | 12 +- .../src/test/resources/snapshot.properties | 8 +- .../snapshots/junit5/SnapshotExtension.java | 20 +- .../BaseClassTest$NestedClass.snap | 3 - ...dClassTest$NestedClassWithoutSnapshot.snap | 3 - ...estedClassTestWithExtends$NestedClass.snap | 3 - .../SnapshotExtensionUsedTest.snap | 28 -- .../__snapshots__/SnapshotParameterTest.snap | 38 --- .../__snapshots__/CustomFrameworkExample.snap | 3 - .../CustomSnapshotConfigExample.snap | 1 - .../CustomSnapshotContextConfigExample.snap | 1 - .../docs/__snapshots__/JUnit5Example.snap | 8 - .../JUnit5ResolutionHierarchyExample.snap | 9 - .../MyFirstSnapshotContextTest.snap | 11 - .../finoid}/snapshots/BaseClassTest.java | 4 +- .../finoid}/snapshots/NestedClassTest.java | 6 +- .../snapshots/NestedClassTestWithExtends.java | 6 +- .../snapshots/SnapshotExtensionUsedTest.java | 6 +- .../snapshots/SnapshotParameterTest.java | 10 +- .../BaseClassTest$NestedClass.snap | 3 + ...dClassTest$NestedClassWithoutSnapshot.snap | 0 ...estedClassTestWithExtends$NestedClass.snap | 3 + .../SnapshotExtensionUsedTest.snap | 28 ++ .../__snapshots__/SnapshotParameterTest.snap | 38 +++ .../docs/CustomFrameworkExample.java | 8 +- .../docs/CustomSnapshotConfigExample.java | 8 +- .../finoid}/snapshots/docs/JUnit5Example.java | 6 +- .../JUnit5ResolutionHierarchyExample.java | 8 +- .../docs/LowercaseToStringSerializer.java | 10 +- .../docs/LowercaseToStringSnapshotConfig.java | 6 +- .../snapshots/docs/MyFirstSnapshotTest.java | 8 +- .../finoid}/snapshots/docs/TestObject.java | 2 +- .../docs/UppercaseToStringSerializer.java | 10 +- .../__snapshots__/CustomFrameworkExample.snap | 3 + .../CustomSnapshotConfigExample.snap | 1 + .../CustomSnapshotContextConfigExample.snap | 0 .../docs/__snapshots__/JUnit5Example.snap | 8 + .../JUnit5ResolutionHierarchyExample.snap | 9 + .../MyFirstSnapshotContextTest.snap | 0 .../__snapshots__/MyFirstSnapshotTest.snap | 12 +- .../src/test/resources/snapshot.properties | 8 +- 228 files changed, 2099 insertions(+), 1537 deletions(-) delete mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java delete mode 100644 snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/Expect.java (90%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/Snapshot.java (96%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotContext.java (90%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotFile.java (99%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotHeader.java (97%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotProperties.java (94%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotSerializerContext.java (93%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotVerifier.java (93%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/annotations/SnapshotName.java (88%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/annotations/UseSnapshotConfig.java (79%) create mode 100644 snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/PlainTextEqualsComparator.java rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/comparators/SnapshotComparator.java (52%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/comparators/v1/PlainTextEqualsComparator.java (58%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/config/PropertyResolvingSnapshotConfig.java (83%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/config/SnapshotConfig.java (92%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/config/SnapshotConfigInjector.java (66%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/exceptions/LogGithubIssueException.java (90%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java (82%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/exceptions/ReservedWordException.java (92%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/exceptions/SnapshotExtensionException.java (85%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/exceptions/SnapshotMatchException.java (91%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/logging/LoggingHelper.java (90%) create mode 100644 snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/PlainTextSnapshotReporter.java rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/reporters/SnapshotReporter.java (61%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/reporters/v1/PlainTextSnapshotReporter.java (89%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/serializers/Base64SnapshotSerializer.java (55%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/serializers/SerializerType.java (57%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/serializers/SnapshotSerializer.java (53%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/serializers/ToStringSnapshotSerializer.java (53%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/serializers/v1/Base64SnapshotSerializer.java (78%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/serializers/v1/ToStringSnapshotSerializer.java (72%) rename snapshot-testing-core/src/main/java/{au/com/origin => io/github/finoid}/snapshots/utils/ReflectionUtils.java (97%) delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap delete mode 100644 snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/CustomFolderSnapshotTest.java (91%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/DebugSnapshotLineEndingsTest.java (83%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/DebugSnapshotTest.java (88%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/EmptySnapshotFileTest.java (79%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/EqualDebugSnapshotFileTest.java (78%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/FakeObject.java (94%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/NoNameChangeTest.java rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/OnLoadSnapshotFileTest.java (82%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/OrphanSnapshotTest.java (85%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/PrivateCalledMethodTest.java (88%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/ReflectionUtilities.java (92%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/ScenarioTest.java (91%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotCaptor.java (96%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotContextTest.java (95%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotHeaders.java (86%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotIntegrationTest.java (88%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotMatcherScenarioTest.java (82%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotMatcherTest.java (83%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotNameAnnotationTest.java (94%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java (68%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotOverrideClassTest.java (83%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotSuperClassTest.java (92%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotTest.java (67%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotUtils.java (92%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/SnapshotUtilsTest.java (94%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/UpdateSnapshotPropertyTest.java (76%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/UpdateSnapshotTest.java (75%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/UseCustomConfigTest.java (79%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/UseCustomSerializerTest.java (88%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/comparators/PlainTextEqualsComparatorTest.java (90%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/config/BaseSnapshotConfig.java (62%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/config/ToStringSnapshotConfig.java (64%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap (100%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap (100%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap (51%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/existing-snapshots/__snapshots__/README.md (100%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap (100%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap (100%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/reporters/PlainTextSnapshotReporterTest.java (89%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/serializers/Base64SnapshotSerializerTest.java (96%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/serializers/LowercaseToStringSerializer.java (68%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/serializers/ToStringSnapshotSerializerTest.java (93%) rename snapshot-testing-core/src/test/java/{au/com/origin => io/github/finoid}/snapshots/serializers/UppercaseToStringSerializer.java (68%) delete mode 100644 snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java delete mode 100644 snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap delete mode 100644 snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap delete mode 100644 snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap delete mode 100644 snapshot-testing-jackson/src/test/resources/snapshot.properties rename {snapshot-testing-jackson => snapshot-testing-jackson2}/pom.xml (97%) rename {snapshot-testing-jackson/src/main/java/au/com/origin => snapshot-testing-jackson2/src/main/java/io/github/finoid}/snapshots/jackson/serializers/DeterministicCollectionModule.java (97%) rename {snapshot-testing-jackson/src/main/java/au/com/origin => snapshot-testing-jackson2/src/main/java/io/github/finoid}/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java (58%) create mode 100644 snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java rename {snapshot-testing-jackson/src/main/java/au/com/origin => snapshot-testing-jackson2/src/main/java/io/github/finoid}/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java (83%) rename {snapshot-testing-jackson/src/main/java/au/com/origin => snapshot-testing-jackson2/src/main/java/io/github/finoid}/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java (88%) rename {snapshot-testing-jackson/src/main/java/au/com/origin => snapshot-testing-jackson2/src/main/java/io/github/finoid}/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java (93%) rename {snapshot-testing-jackson/src/test/java/au/com/origin => snapshot-testing-jackson2/src/test/java/io/github/finoid}/snapshots/jackson/NoNameChangeTest.java (54%) rename {snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3 => snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson}/ReflectionUtilities.java (91%) rename {snapshot-testing-jackson/src/test/java/au/com/origin => snapshot-testing-jackson2/src/test/java/io/github/finoid}/snapshots/jackson/docs/BaseEntity.java (86%) rename {snapshot-testing-jackson/src/test/java/au/com/origin => snapshot-testing-jackson2/src/test/java/io/github/finoid}/snapshots/jackson/docs/CustomSerializerTest.java (75%) rename {snapshot-testing-jackson/src/test/java/au/com/origin => snapshot-testing-jackson2/src/test/java/io/github/finoid}/snapshots/jackson/docs/HibernateSnapshotSerializer.java (88%) rename {snapshot-testing-jackson/src/test/java/au/com/origin => snapshot-testing-jackson2/src/test/java/io/github/finoid}/snapshots/jackson/docs/JsonAssertReporter.java (71%) rename {snapshot-testing-jackson/src/test/java/au/com/origin => snapshot-testing-jackson2/src/test/java/io/github/finoid}/snapshots/jackson/docs/JsonObjectComparator.java (78%) create mode 100644 snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap rename {snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1 => snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers}/DeterministicJacksonSnapshotSerializerTest.java (95%) rename {snapshot-testing-jackson/src/test/java/au/com/origin => snapshot-testing-jackson2/src/test/java/io/github/finoid}/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java (91%) create mode 100644 snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap create mode 100644 snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap create mode 100644 snapshot-testing-jackson2/src/test/resources/snapshot.properties rename snapshot-testing-jackson3/src/main/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java (97%) rename snapshot-testing-jackson3/src/main/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java (92%) rename snapshot-testing-jackson3/src/main/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java (90%) delete mode 100644 snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap delete mode 100644 snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap delete mode 100644 snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap rename snapshot-testing-jackson3/src/test/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/NoNameChangeTest.java (53%) rename {snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson => snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3}/ReflectionUtilities.java (91%) rename snapshot-testing-jackson3/src/test/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/docs/BaseEntity.java (86%) rename snapshot-testing-jackson3/src/test/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/docs/CustomSerializerTest.java (75%) rename snapshot-testing-jackson3/src/test/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/docs/HibernateSnapshotSerializer.java (87%) rename snapshot-testing-jackson3/src/test/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/docs/JsonAssertReporter.java (71%) rename snapshot-testing-jackson3/src/test/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/docs/JsonObjectComparator.java (77%) create mode 100644 snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap rename {snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers => snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1}/DeterministicJacksonSnapshotSerializerTest.java (94%) rename snapshot-testing-jackson3/src/test/java/{au/com/origin => io/github/finoid}/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java (91%) create mode 100644 snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap create mode 100644 snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap rename {snapshot-testing-junit6/src/main/java/au/com/origin => snapshot-testing-junit5/src/main/java/io/github/finoid}/snapshots/junit5/SnapshotExtension.java (89%) delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap delete mode 100644 snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/BaseClassTest.java (82%) rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/NestedClassTest.java (84%) rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/NestedClassTestWithExtends.java (79%) rename {snapshot-testing-junit6/src/test/java/au/com/origin => snapshot-testing-junit5/src/test/java/io/github/finoid}/snapshots/SnapshotExtensionUsedTest.java (85%) rename {snapshot-testing-junit6/src/test/java/au/com/origin => snapshot-testing-junit5/src/test/java/io/github/finoid}/snapshots/SnapshotParameterTest.java (83%) create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap rename {snapshot-testing-junit6/src/test/java/au/com/origin => snapshot-testing-junit5/src/test/java/io/github/finoid}/snapshots/docs/CustomFrameworkExample.java (78%) rename {snapshot-testing-junit6/src/test/java/au/com/origin => snapshot-testing-junit5/src/test/java/io/github/finoid}/snapshots/docs/CustomSnapshotConfigExample.java (65%) rename {snapshot-testing-junit6/src/test/java/au/com/origin => snapshot-testing-junit5/src/test/java/io/github/finoid}/snapshots/docs/JUnit5Example.java (80%) rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/JUnit5ResolutionHierarchyExample.java (80%) rename {snapshot-testing-junit6/src/test/java/au/com/origin => snapshot-testing-junit5/src/test/java/io/github/finoid}/snapshots/docs/LowercaseToStringSerializer.java (55%) rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/LowercaseToStringSnapshotConfig.java (53%) rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/MyFirstSnapshotTest.java (76%) rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/TestObject.java (77%) rename {snapshot-testing-junit6/src/test/java/au/com/origin => snapshot-testing-junit5/src/test/java/io/github/finoid}/snapshots/docs/UppercaseToStringSerializer.java (55%) create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename snapshot-testing-junit5/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap (58%) rename {snapshot-testing-junit5/src/main/java/au/com/origin => snapshot-testing-junit6/src/main/java/io/github/finoid}/snapshots/junit5/SnapshotExtension.java (89%) delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap delete mode 100644 snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/BaseClassTest.java (82%) rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/NestedClassTest.java (84%) rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/NestedClassTestWithExtends.java (79%) rename {snapshot-testing-junit5/src/test/java/au/com/origin => snapshot-testing-junit6/src/test/java/io/github/finoid}/snapshots/SnapshotExtensionUsedTest.java (85%) rename {snapshot-testing-junit5/src/test/java/au/com/origin => snapshot-testing-junit6/src/test/java/io/github/finoid}/snapshots/SnapshotParameterTest.java (83%) create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap rename {snapshot-testing-junit5/src/test/java/au/com/origin => snapshot-testing-junit6/src/test/java/io/github/finoid}/snapshots/docs/CustomFrameworkExample.java (78%) rename {snapshot-testing-junit5/src/test/java/au/com/origin => snapshot-testing-junit6/src/test/java/io/github/finoid}/snapshots/docs/CustomSnapshotConfigExample.java (65%) rename {snapshot-testing-junit5/src/test/java/au/com/origin => snapshot-testing-junit6/src/test/java/io/github/finoid}/snapshots/docs/JUnit5Example.java (80%) rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/JUnit5ResolutionHierarchyExample.java (80%) rename {snapshot-testing-junit5/src/test/java/au/com/origin => snapshot-testing-junit6/src/test/java/io/github/finoid}/snapshots/docs/LowercaseToStringSerializer.java (55%) rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/LowercaseToStringSnapshotConfig.java (53%) rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/MyFirstSnapshotTest.java (76%) rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/TestObject.java (77%) rename {snapshot-testing-junit5/src/test/java/au/com/origin => snapshot-testing-junit6/src/test/java/io/github/finoid}/snapshots/docs/UppercaseToStringSerializer.java (55%) create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename snapshot-testing-junit6/src/test/java/{au/com/origin => io/github/finoid}/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap (58%) diff --git a/README.md b/README.md index ea15ef4..f024a49 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -[![Build Status](https://github.com/origin-energy/java-snapshot-testing/workflows/build/badge.svg)](https://github.com/origin-energy/java-snapshot-testing/actions) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.origin-energy/java-snapshot-testing-core/badge.svg)](https://search.maven.org/artifact/io.github.origin-energy/java-snapshot-testing-core/3.2.7/jar) - # Java Snapshot Testing + - Inspired by [facebook's Jest framework](https://facebook.github.io/jest/docs/en/snapshot-testing.html) -- Fork of https://github.com/origin-energy/java-snapshot-testing +- Fork of https://github.com/origin-energy/java-snapshot-testing \ No newline at end of file diff --git a/pom.xml b/pom.xml index 886cb2d..73cf7c2 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ snapshot-testing-core - snapshot-testing-jackson + snapshot-testing-jackson2 snapshot-testing-jackson3 snapshot-testing-junit5 snapshot-testing-junit6 @@ -58,7 +58,7 @@ io.github.finoid - snapshot-testing-jackson + snapshot-testing-jackson2 ${revision} diff --git a/snapshot-testing-core/.gitignore b/snapshot-testing-core/.gitignore index be3f6ef..fa1ce7d 100644 --- a/snapshot-testing-core/.gitignore +++ b/snapshot-testing-core/.gitignore @@ -1,4 +1,4 @@ -src/test/java/au/com/origin/snapshots/__snapshots__/ +src/test/java/io/github/finoid/snapshots/__snapshots__/ src/test/some-folder/ anyFilePath.debug blah \ No newline at end of file diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java deleted file mode 100644 index d5d0e4f..0000000 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparator.java +++ /dev/null @@ -1,17 +0,0 @@ -package au.com.origin.snapshots.comparators; - -import au.com.origin.snapshots.logging.LoggingHelper; -import lombok.extern.slf4j.Slf4j; - -@Deprecated -@Slf4j -public class PlainTextEqualsComparator - extends au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator { - - public PlainTextEqualsComparator() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator` in `snapshot.properties`"); - } -} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java b/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java deleted file mode 100644 index 218b6c0..0000000 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporter.java +++ /dev/null @@ -1,17 +0,0 @@ -package au.com.origin.snapshots.reporters; - -import au.com.origin.snapshots.logging.LoggingHelper; -import lombok.extern.slf4j.Slf4j; - -@Deprecated -@Slf4j -public class PlainTextSnapshotReporter - extends au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter { - - public PlainTextSnapshotReporter() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter` in `snapshot.properties`"); - } -} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/Expect.java similarity index 90% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/Expect.java index ec6c980..1fd827a 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Expect.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/Expect.java @@ -1,8 +1,10 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.Base64SnapshotSerializer; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.serializers.ToStringSnapshotSerializer; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -12,6 +14,7 @@ import java.util.List; import java.util.Map; +@SuppressWarnings("NullAway") // TODO (nw) refactor @RequiredArgsConstructor public class Expect { private final SnapshotVerifier snapshotVerifier; @@ -97,9 +100,9 @@ public Expect serializer(String name) { * * @param serializer your custom serializer * @return this - * @see au.com.origin.snapshots.serializers.SnapshotSerializer - * @see au.com.origin.snapshots.serializers.ToStringSnapshotSerializer - * @see au.com.origin.snapshots.serializers.Base64SnapshotSerializer + * @see SnapshotSerializer + * @see ToStringSnapshotSerializer + * @see Base64SnapshotSerializer */ @SneakyThrows public Expect serializer(Class serializer) { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/Snapshot.java similarity index 96% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/Snapshot.java index 9db0d0c..a0e5e8c 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/Snapshot.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/Snapshot.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.exceptions.LogGithubIssueException; +import io.github.finoid.snapshots.exceptions.LogGithubIssueException; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotContext.java similarity index 90% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotContext.java index eb66022..812b48f 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotContext.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotContext.java @@ -1,13 +1,13 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.ReservedWordException; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +package io.github.finoid.snapshots; + +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.ReservedWordException; +import io.github.finoid.snapshots.exceptions.SnapshotExtensionException; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -21,6 +21,7 @@ import java.util.stream.Collectors; @Slf4j +@SuppressWarnings("NullAway") // TODO (nw) refactor public class SnapshotContext { private static final List RESERVED_WORDS = Arrays.asList("=", "[", "]"); @@ -47,6 +48,7 @@ public class SnapshotContext { @Setter private List snapshotReporters; + @SuppressWarnings("NullAway") // TODO (nw) refactor SnapshotContext( SnapshotConfig snapshotConfig, SnapshotFile snapshotFile, diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotFile.java similarity index 99% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotFile.java index 7a055e2..cc6b296 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotFile.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotFile.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; import lombok.Getter; import lombok.SneakyThrows; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotHeader.java similarity index 97% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotHeader.java index 3bd7739..3f3870c 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotHeader.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotHeader.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotProperties.java similarity index 94% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotProperties.java index 044e336..a9550a9 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotProperties.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotProperties.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.exceptions.MissingSnapshotPropertiesKeyException; +import io.github.finoid.snapshots.exceptions.MissingSnapshotPropertiesKeyException; import lombok.extern.slf4j.Slf4j; import java.io.InputStream; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotSerializerContext.java similarity index 93% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotSerializerContext.java index 1292866..6d2ca61 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotSerializerContext.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotSerializerContext.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.annotations.SnapshotName; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotVerifier.java similarity index 93% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotVerifier.java index a6030f7..fc7c8af 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/SnapshotVerifier.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/SnapshotVerifier.java @@ -1,10 +1,10 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.annotations.UseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotExtensionException; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -47,6 +47,7 @@ public SnapshotVerifier(SnapshotConfig frameworkSnapshotConfig, Class testCla * @param testClass reference to class under test */ @SneakyThrows + @SuppressWarnings("NullAway") // TODO (nw) refactor public SnapshotVerifier( SnapshotConfig frameworkSnapshotConfig, Class testClass, boolean failOnOrphans) { try { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/annotations/SnapshotName.java similarity index 88% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/annotations/SnapshotName.java index ff454c7..de73ce7 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/SnapshotName.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/annotations/SnapshotName.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.annotations; +package io.github.finoid.snapshots.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/annotations/UseSnapshotConfig.java similarity index 79% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/annotations/UseSnapshotConfig.java index e269e39..800a335 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/annotations/UseSnapshotConfig.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/annotations/UseSnapshotConfig.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.annotations; +package io.github.finoid.snapshots.annotations; -import au.com.origin.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/PlainTextEqualsComparator.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/PlainTextEqualsComparator.java new file mode 100644 index 0000000..10ab573 --- /dev/null +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/PlainTextEqualsComparator.java @@ -0,0 +1,17 @@ +package io.github.finoid.snapshots.comparators; + +import io.github.finoid.snapshots.logging.LoggingHelper; +import lombok.extern.slf4j.Slf4j; + +@Deprecated +@Slf4j +public class PlainTextEqualsComparator + extends io.github.finoid.snapshots.comparators.v1.PlainTextEqualsComparator { + + public PlainTextEqualsComparator() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `v1.comparators.io.github.finoid.snapshots.PlainTextEqualsComparator` in `snapshot.properties`"); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/SnapshotComparator.java similarity index 52% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/SnapshotComparator.java index 934a07b..e4e85a3 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/SnapshotComparator.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/SnapshotComparator.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.comparators; +package io.github.finoid.snapshots.comparators; -import au.com.origin.snapshots.Snapshot; +import io.github.finoid.snapshots.Snapshot; public interface SnapshotComparator { boolean matches(Snapshot previous, Snapshot current); diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/v1/PlainTextEqualsComparator.java similarity index 58% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/v1/PlainTextEqualsComparator.java index c300909..deb37d0 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/comparators/v1/PlainTextEqualsComparator.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/comparators/v1/PlainTextEqualsComparator.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.comparators.v1; +package io.github.finoid.snapshots.comparators.v1; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.comparators.SnapshotComparator; public class PlainTextEqualsComparator implements SnapshotComparator { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/PropertyResolvingSnapshotConfig.java similarity index 83% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/PropertyResolvingSnapshotConfig.java index 05e8b6a..7f40607 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/PropertyResolvingSnapshotConfig.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/PropertyResolvingSnapshotConfig.java @@ -1,11 +1,11 @@ -package au.com.origin.snapshots.config; +package io.github.finoid.snapshots.config; -import au.com.origin.snapshots.SnapshotProperties; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.exceptions.MissingSnapshotPropertiesKeyException; -import au.com.origin.snapshots.logging.LoggingHelper; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.SnapshotProperties; +import io.github.finoid.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.exceptions.MissingSnapshotPropertiesKeyException; +import io.github.finoid.snapshots.logging.LoggingHelper; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import lombok.extern.slf4j.Slf4j; import java.util.List; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/SnapshotConfig.java similarity index 92% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/SnapshotConfig.java index 6af4c12..9d1ed6f 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfig.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/SnapshotConfig.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.config; +package io.github.finoid.snapshots.config; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import java.util.List; import java.util.Optional; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/SnapshotConfigInjector.java similarity index 66% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/SnapshotConfigInjector.java index 0284aa8..404be51 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/config/SnapshotConfigInjector.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/config/SnapshotConfigInjector.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.config; +package io.github.finoid.snapshots.config; public interface SnapshotConfigInjector { SnapshotConfig getSnapshotConfig(); diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/LogGithubIssueException.java similarity index 90% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/LogGithubIssueException.java index a19bfdf..c9481d5 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/LogGithubIssueException.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/LogGithubIssueException.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.exceptions; +package io.github.finoid.snapshots.exceptions; public class LogGithubIssueException extends RuntimeException { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java similarity index 82% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java index 2b8b9a6..b477b50 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/MissingSnapshotPropertiesKeyException.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.exceptions; +package io.github.finoid.snapshots.exceptions; public class MissingSnapshotPropertiesKeyException extends RuntimeException { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/ReservedWordException.java similarity index 92% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/ReservedWordException.java index 6579c05..d4247b4 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/ReservedWordException.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/ReservedWordException.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.exceptions; +package io.github.finoid.snapshots.exceptions; import java.util.List; import java.util.stream.Collectors; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/SnapshotExtensionException.java similarity index 85% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/SnapshotExtensionException.java index a78d8f6..86043a4 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotExtensionException.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/SnapshotExtensionException.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.exceptions; +package io.github.finoid.snapshots.exceptions; public class SnapshotExtensionException extends RuntimeException { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/SnapshotMatchException.java similarity index 91% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/SnapshotMatchException.java index 78fcaab..78a2a11 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/exceptions/SnapshotMatchException.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/exceptions/SnapshotMatchException.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.exceptions; +package io.github.finoid.snapshots.exceptions; import org.opentest4j.MultipleFailuresError; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/logging/LoggingHelper.java similarity index 90% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/logging/LoggingHelper.java index 240181b..8c31a20 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/logging/LoggingHelper.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/logging/LoggingHelper.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.logging; +package io.github.finoid.snapshots.logging; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/PlainTextSnapshotReporter.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/PlainTextSnapshotReporter.java new file mode 100644 index 0000000..8b11cb4 --- /dev/null +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/PlainTextSnapshotReporter.java @@ -0,0 +1,17 @@ +package io.github.finoid.snapshots.reporters; + +import io.github.finoid.snapshots.logging.LoggingHelper; +import lombok.extern.slf4j.Slf4j; + +@Deprecated +@Slf4j +public class PlainTextSnapshotReporter + extends io.github.finoid.snapshots.reporters.v1.PlainTextSnapshotReporter { + + public PlainTextSnapshotReporter() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `v1.reporters.io.github.finoid.snapshots.PlainTextSnapshotReporter` in `snapshot.properties`"); + } +} diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/SnapshotReporter.java similarity index 61% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/SnapshotReporter.java index ab6d2f6..30f68fe 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/SnapshotReporter.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/SnapshotReporter.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.reporters; +package io.github.finoid.snapshots.reporters; -import au.com.origin.snapshots.Snapshot; +import io.github.finoid.snapshots.Snapshot; public interface SnapshotReporter { diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/v1/PlainTextSnapshotReporter.java similarity index 89% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/v1/PlainTextSnapshotReporter.java index 209e11b..bfb33b9 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/reporters/v1/PlainTextSnapshotReporter.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/reporters/v1/PlainTextSnapshotReporter.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.reporters.v1; +package io.github.finoid.snapshots.reporters.v1; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.reporters.SnapshotReporter; import org.assertj.core.util.diff.DiffUtils; import org.assertj.core.util.diff.Patch; import org.opentest4j.AssertionFailedError; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/Base64SnapshotSerializer.java similarity index 55% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/Base64SnapshotSerializer.java index 3551fb9..b4a4530 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/Base64SnapshotSerializer.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; -import au.com.origin.snapshots.logging.LoggingHelper; +import io.github.finoid.snapshots.logging.LoggingHelper; import lombok.extern.slf4j.Slf4j; /** @@ -10,11 +10,11 @@ @Slf4j @Deprecated public class Base64SnapshotSerializer - extends au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer { + extends io.github.finoid.snapshots.serializers.v1.Base64SnapshotSerializer { public Base64SnapshotSerializer() { super(); LoggingHelper.deprecatedV5( log, - "Update to `au.com.origin.snapshots.serializers.v1.Base64SnapshotSerializer` in `snapshot.properties`"); + "Update to `v1.serializers.io.github.finoid.snapshots.Base64SnapshotSerializer` in `snapshot.properties`"); } } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/SerializerType.java similarity index 57% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/SerializerType.java index 4f320c0..780ae0b 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SerializerType.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/SerializerType.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; public enum SerializerType { TEXT, diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/SnapshotSerializer.java similarity index 53% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/SnapshotSerializer.java index a0dca36..d1ee3e8 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/SnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/SnapshotSerializer.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; import java.util.function.BiFunction; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/ToStringSnapshotSerializer.java similarity index 53% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/ToStringSnapshotSerializer.java index e7c5153..5925b06 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/ToStringSnapshotSerializer.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; -import au.com.origin.snapshots.logging.LoggingHelper; +import io.github.finoid.snapshots.logging.LoggingHelper; import lombok.extern.slf4j.Slf4j; /** @@ -11,11 +11,11 @@ @Slf4j @Deprecated public class ToStringSnapshotSerializer - extends au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer { + extends io.github.finoid.snapshots.serializers.v1.ToStringSnapshotSerializer { public ToStringSnapshotSerializer() { super(); LoggingHelper.deprecatedV5( log, - "Update to `au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer` in `snapshot.properties`"); + "Update to `v1.serializers.io.github.finoid.snapshots.ToStringSnapshotSerializer` in `snapshot.properties`"); } } diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/v1/Base64SnapshotSerializer.java similarity index 78% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/v1/Base64SnapshotSerializer.java index 7ed91ad..85ad1d4 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/Base64SnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/v1/Base64SnapshotSerializer.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.serializers.v1; +package io.github.finoid.snapshots.serializers.v1; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import java.nio.charset.StandardCharsets; import java.util.Base64; diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/v1/ToStringSnapshotSerializer.java similarity index 72% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/v1/ToStringSnapshotSerializer.java index 6d5bbf0..8222850 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/v1/ToStringSnapshotSerializer.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/serializers/v1/ToStringSnapshotSerializer.java @@ -1,10 +1,10 @@ -package au.com.origin.snapshots.serializers.v1; +package io.github.finoid.snapshots.serializers.v1; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotFile; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotFile; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import lombok.extern.slf4j.Slf4j; /** diff --git a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/utils/ReflectionUtils.java similarity index 97% rename from snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java rename to snapshot-testing-core/src/main/java/io/github/finoid/snapshots/utils/ReflectionUtils.java index 91614a1..6571ff8 100644 --- a/snapshot-testing-core/src/main/java/au/com/origin/snapshots/utils/ReflectionUtils.java +++ b/snapshot-testing-core/src/main/java/io/github/finoid/snapshots/utils/ReflectionUtils.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.utils; +package io.github.finoid.snapshots.utils; import lombok.experimental.UtilityClass; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java deleted file mode 100644 index 15785a7..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/NoNameChangeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package au.com.origin.snapshots; - -import au.com.origin.snapshots.comparators.PlainTextEqualsComparator; -import au.com.origin.snapshots.reporters.PlainTextSnapshotReporter; -import au.com.origin.snapshots.serializers.Base64SnapshotSerializer; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * These classes are likely defined in snapshot.properties as a string. - * - *

The clients IDE will not complain if they change so ensure they don't - */ -public class NoNameChangeTest { - - @Test - public void serializersApiShouldNotChange() { - assertThat(Base64SnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.serializers.Base64SnapshotSerializer"); - assertThat(ToStringSnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.serializers.ToStringSnapshotSerializer"); - assertThat(SerializerType.class.getName()) - .isEqualTo("au.com.origin.snapshots.serializers.SerializerType"); - } - - @Test - public void reportersApiShouldNotChange() { - assertThat(PlainTextSnapshotReporter.class.getName()) - .isEqualTo("au.com.origin.snapshots.reporters.PlainTextSnapshotReporter"); - } - - @Test - public void comparatorsApiShouldNotChange() { - assertThat(PlainTextEqualsComparator.class.getName()) - .isEqualTo("au.com.origin.snapshots.comparators.PlainTextEqualsComparator"); - } -} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap deleted file mode 100644 index def0f2f..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap +++ /dev/null @@ -1,4 +0,0 @@ -au.com.origin.snapshots.DebugSnapshotLineEndingsTest.existingSnapshotDifferentLineEndings=[ -a -b -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap deleted file mode 100644 index ad53cf0..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap +++ /dev/null @@ -1,13 +0,0 @@ -au.com.origin.snapshots.DebugSnapshotTest.createDebugFile=[ -Good Snapshot -] - - -au.com.origin.snapshots.DebugSnapshotTest.debugFileCreatedSnapshotMatch=[ -Good Snapshot -] - - -au.com.origin.snapshots.DebugSnapshotTest.debugFileCreatedExistingSnapshot=[ -Good Snapshot -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap deleted file mode 100644 index ad53cf0..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap +++ /dev/null @@ -1,13 +0,0 @@ -au.com.origin.snapshots.DebugSnapshotTest.createDebugFile=[ -Good Snapshot -] - - -au.com.origin.snapshots.DebugSnapshotTest.debugFileCreatedSnapshotMatch=[ -Good Snapshot -] - - -au.com.origin.snapshots.DebugSnapshotTest.debugFileCreatedExistingSnapshot=[ -Good Snapshot -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap deleted file mode 100644 index ac99c35..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.PrivateCalledMethodTest.testName=[ -testContent -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap deleted file mode 100644 index 209ac10..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap +++ /dev/null @@ -1,28 +0,0 @@ -au.com.origin.snapshots.ScenarioTest.canTakeMultipleSnapshotsUsingScenario=[ -Default Snapshot -] - - -au.com.origin.snapshots.ScenarioTest.canTakeMultipleSnapshotsUsingScenario[additional]=[ -Additional Snapshot -] - - -au.com.origin.snapshots.ScenarioTest.canTakeTheSameSnapshotTwice=[ -Default Snapshot -] - - -au.com.origin.snapshots.ScenarioTest.canTakeTheSameSnapshotTwice[scenario]=[ -Scenario Snapshot -] - - -au.com.origin.snapshots.ScenarioTest.cannotTakeDifferentSnapshotsAtDefaultLevel=[ -Default Snapshot -] - - -au.com.origin.snapshots.ScenarioTest.cannotTakeDifferentSnapshotsAtScenarioLevel[scenario]=[ -Default Snapshot -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap deleted file mode 100644 index 5fa1e53..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap +++ /dev/null @@ -1,10 +0,0 @@ -au.com.origin.snapshots.SnapshotHeaders.shouldBeAbleToSnapshotASingleCustomHeader={ - "custom": "anything", - "custom2": "anything2" -}hello world - - -au.com.origin.snapshots.SnapshotHeaders.shouldBeAbleToSnapshotMultipleCustomHeader={ - "custom": "anything", - "custom2": "anything2" -}hello world \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap deleted file mode 100644 index 8e7a6de..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap +++ /dev/null @@ -1,37 +0,0 @@ -au.com.origin.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotFour=[ -FakeObject(id=anyId4, value=4, name=any -. -. -Name4, fakeObject=null) -] - - -au.com.origin.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotInsidePrivateMethod=[ -FakeObject(id=anyPrivate, value=5, name=anyPrivate, fakeObject=null) -] - - -au.com.origin.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotOne=[ -FakeObject(id=anyId1, value=1, name=anyName1, fakeObject=null) -] - - -au.com.origin.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotThree=[ -FakeObject(id=anyId3, value=3, name=anyName3, fakeObject=null) -] - - -au.com.origin.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotTwo=[ -FakeObject(id=anyId2, value=2, name=anyName2, fakeObject=null) -] - - -au.com.origin.snapshots.SnapshotIntegrationTest.shouldSnapshotUsingSerializerClass=HELLO WORLD - - -au.com.origin.snapshots.SnapshotIntegrationTest.shouldSnapshotUsingSerializerPropertyName=hello world - - -au.com.origin.snapshots.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=[ -FakeObject(id=anyId5, value=7, name=anyName5, fakeObject=null) -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap deleted file mode 100644 index b9f842c..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.SnapshotOverrideClassTest.shouldMatchSnapshotOne=[ -anyName -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap deleted file mode 100644 index 9cf2c6c..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap +++ /dev/null @@ -1,8 +0,0 @@ -au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[ -FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null) -] - - -au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[ -FakeObject(id=ERROR, value=1, name=anyName2, fakeObject=null) -] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap deleted file mode 100644 index e25ac7b..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap +++ /dev/null @@ -1,4 +0,0 @@ -au.com.origin.snapshots.UseCustomConfigTest.canUseSnapshotConfigAnnotationAtClassLevel=This is a snapshot of the toString() method - - -au.com.origin.snapshots.UseCustomConfigTest.canUseSnapshotConfigAnnotationAtMethodLevel=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap b/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap deleted file mode 100644 index 5d5d5bb..0000000 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap +++ /dev/null @@ -1,10 +0,0 @@ -au.com.origin.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtClassLevel=this is a snapshot of the tostring() method - - -au.com.origin.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtMethodLevel=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD - - -au.com.origin.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtMethodLevelUsingClassName=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD - - -au.com.origin.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtMethodLevelUsingNewInstance=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/CustomFolderSnapshotTest.java similarity index 91% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/CustomFolderSnapshotTest.java index 27e33fb..4290de6 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/CustomFolderSnapshotTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/CustomFolderSnapshotTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -14,7 +14,7 @@ public class CustomFolderSnapshotTest { private static final String OUTPUT_FILE = - "src/test/some-folder/au/com/origin/snapshots/__snapshots__/CustomFolderSnapshotTest.snap"; + "src/test/some-folder/io/github/finoid/snapshots/__snapshots__/CustomFolderSnapshotTest.snap"; @BeforeEach public void beforeEach() throws IOException { diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/DebugSnapshotLineEndingsTest.java similarity index 83% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/DebugSnapshotLineEndingsTest.java index 1fa8889..0f0db76 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotLineEndingsTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/DebugSnapshotLineEndingsTest.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -29,9 +29,9 @@ public SnapshotSerializer getSerializer() { } }; private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap.debug"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap.debug"; private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap"; @BeforeAll static void beforeAll() { @@ -89,7 +89,7 @@ public Snapshot apply(Object object, SnapshotSerializerContext snapshotSerialize return Snapshot.builder() .name( - "au.com.origin.snapshots.DebugSnapshotLineEndingsTest.existingSnapshotDifferentLineEndings") + "io.github.finoid.snapshots.DebugSnapshotLineEndingsTest.existingSnapshotDifferentLineEndings") .body(body.toString()) .build(); } diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/DebugSnapshotTest.java similarity index 88% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/DebugSnapshotTest.java index 47735ba..366f395 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/DebugSnapshotTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/DebugSnapshotTest.java @@ -1,10 +1,10 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.serializers.ToStringSnapshotSerializer; import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -32,9 +32,9 @@ public SnapshotSerializer getSerializer() { }; private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotTest.snap.debug"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/DebugSnapshotTest.snap.debug"; private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/DebugSnapshotTest.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/DebugSnapshotTest.snap"; @BeforeAll static void beforeAll() { diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/EmptySnapshotFileTest.java similarity index 79% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/EmptySnapshotFileTest.java index 4afb9ed..9c674ab 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EmptySnapshotFileTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/EmptySnapshotFileTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.ToStringSnapshotConfig; +import io.github.finoid.snapshots.config.ToStringSnapshotConfig; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -15,9 +15,9 @@ public class EmptySnapshotFileTest { private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/EmptySnapshotFileTest.snap"; private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug"; @BeforeAll static void beforeAll() { @@ -42,9 +42,9 @@ public void shouldRemoveEmptySnapshots(TestInfo testInfo) { public class NestedClass { private static final String SNAPSHOT_FILE_PATH_NESTED = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap"; private static final String DEBUG_FILE_PATH_NESTED = - "src/test/java/au/com/origin/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug"; @DisplayName("Should remove empty nested snapshots") @Test diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/EqualDebugSnapshotFileTest.java similarity index 78% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/EqualDebugSnapshotFileTest.java index 2cf884f..3b251b9 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/EqualDebugSnapshotFileTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/EqualDebugSnapshotFileTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.ToStringSnapshotConfig; +import io.github.finoid.snapshots.config.ToStringSnapshotConfig; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -14,9 +14,9 @@ public class EqualDebugSnapshotFileTest { private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap"; private static final String DEBUG_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug"; @BeforeAll static void beforeAll() { diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/FakeObject.java similarity index 94% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/FakeObject.java index a36a9e7..0c62841 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/FakeObject.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/FakeObject.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/NoNameChangeTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/NoNameChangeTest.java new file mode 100644 index 0000000..00529ec --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/NoNameChangeTest.java @@ -0,0 +1,40 @@ +package io.github.finoid.snapshots; + +import io.github.finoid.snapshots.comparators.PlainTextEqualsComparator; +import io.github.finoid.snapshots.reporters.PlainTextSnapshotReporter; +import io.github.finoid.snapshots.serializers.Base64SnapshotSerializer; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.ToStringSnapshotSerializer; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * These classes are likely defined in snapshot.properties as a string. + * + *

The clients IDE will not complain if they change so ensure they don't + */ +public class NoNameChangeTest { + + @Test + public void serializersApiShouldNotChange() { + assertThat(Base64SnapshotSerializer.class.getName()) + .isEqualTo("io.github.finoid.snapshots.serializers.Base64SnapshotSerializer"); + assertThat(ToStringSnapshotSerializer.class.getName()) + .isEqualTo("io.github.finoid.snapshots.serializers.ToStringSnapshotSerializer"); + assertThat(SerializerType.class.getName()) + .isEqualTo("io.github.finoid.snapshots.serializers.SerializerType"); + } + + @Test + public void reportersApiShouldNotChange() { + assertThat(PlainTextSnapshotReporter.class.getName()) + .isEqualTo("io.github.finoid.snapshots.reporters.PlainTextSnapshotReporter"); + } + + @Test + public void comparatorsApiShouldNotChange() { + assertThat(PlainTextEqualsComparator.class.getName()) + .isEqualTo("io.github.finoid.snapshots.comparators.PlainTextEqualsComparator"); + } +} diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/OnLoadSnapshotFileTest.java similarity index 82% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/OnLoadSnapshotFileTest.java index 6380c01..43b5d3a 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OnLoadSnapshotFileTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/OnLoadSnapshotFileTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.serializers.ToStringSnapshotSerializer; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -21,7 +21,7 @@ public class OnLoadSnapshotFileTest { private static final String SNAPSHOT_FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/OnLoadSnapshotFileTest.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/OnLoadSnapshotFileTest.snap"; private static final SnapshotConfig CUSTOM_SNAPSHOT_CONFIG = new BaseSnapshotConfig(); @@ -29,7 +29,7 @@ public class OnLoadSnapshotFileTest { static void beforeAll() throws IOException { Files.deleteIfExists(Paths.get(SNAPSHOT_FILE_PATH)); String snapshotFileContent = - "au.com.origin.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" + "io.github.finoid.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" + "any special characters that need correct encoding äöüèéàè\n" + "]"; createSnapshotFile(snapshotFileContent); @@ -66,7 +66,7 @@ public void shouldLoadFileWithCorrectEncodingForCompare(TestInfo testInfo) throw File f = new File(SNAPSHOT_FILE_PATH); assertThat(String.join("\n", Files.readAllLines(f.toPath()))) .isEqualTo( - "au.com.origin.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" + "io.github.finoid.snapshots.OnLoadSnapshotFileTest.shouldLoadFileWithCorrectEncodingForCompare=[\n" + "any special characters that need correct encoding äöüèéàè\n" + "]"); } diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/OrphanSnapshotTest.java similarity index 85% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/OrphanSnapshotTest.java index 16e6bb9..d2bbb15 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/OrphanSnapshotTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/OrphanSnapshotTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -32,7 +32,7 @@ void orphanSnapshotsShouldFailTheBuild(TestInfo testInfo) throws IOException { new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get(), true); FakeObject fakeObject1 = FakeObject.builder().id("anyId1").value(1).name("anyName1").build(); final Path snapshotFile = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/OrphanSnapshotTest.snap"); + Paths.get("src/test/java/io/github/finoid/snapshots/__snapshots__/OrphanSnapshotTest.snap"); long bytesBefore = Files.size(snapshotFile); @@ -60,7 +60,7 @@ void orphanSnapshotsShouldNotFailTheBuild(TestInfo testInfo) throws IOException new SnapshotVerifier(DEFAULT_CONFIG, testInfo.getTestClass().get(), false); FakeObject fakeObject1 = FakeObject.builder().id("anyId1").value(1).name("anyName1").build(); final Path snapshotFile = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/OrphanSnapshotTest.snap"); + Paths.get("src/test/java/io/github/finoid/snapshots/__snapshots__/OrphanSnapshotTest.snap"); long bytesBefore = Files.size(snapshotFile); diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/PrivateCalledMethodTest.java similarity index 88% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/PrivateCalledMethodTest.java index 01b067d..542c11a 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/PrivateCalledMethodTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/PrivateCalledMethodTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/ReflectionUtilities.java similarity index 92% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/ReflectionUtilities.java index ca86c6c..82cc559 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ReflectionUtilities.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/ReflectionUtilities.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/ScenarioTest.java similarity index 91% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/ScenarioTest.java index e861964..149e5d4 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/ScenarioTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/ScenarioTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotCaptor.java similarity index 96% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotCaptor.java index 42b9b91..bd70a18 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotCaptor.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotCaptor.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; +import io.github.finoid.snapshots.exceptions.SnapshotExtensionException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotContextTest.java similarity index 95% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotContextTest.java index e35dd5e..f17786b 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotContextTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotContextTest.java @@ -1,10 +1,10 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.ToStringSnapshotSerializer; import lombok.SneakyThrows; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotHeaders.java similarity index 86% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotHeaders.java index 2f98ba0..696bb8e 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotHeaders.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotHeaders.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.LowercaseToStringSerializer; -import au.com.origin.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.serializers.LowercaseToStringSerializer; +import io.github.finoid.snapshots.serializers.SerializerType; import lombok.NoArgsConstructor; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotIntegrationTest.java similarity index 88% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotIntegrationTest.java index 2abe87f..86ce81c 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotIntegrationTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotIntegrationTest.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.serializers.UppercaseToStringSerializer; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.serializers.UppercaseToStringSerializer; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -69,7 +69,7 @@ void shouldThrowSnapshotMatchException(TestInfo testInfo) { expect.toMatchSnapshot( FakeObject.builder().id("anyId5").value(6).name("anyName5").build()), "Error on: \n" - + "au.com.origin.snapshots.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=["); + + "io.github.finoid.snapshots.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=["); } @Test diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotMatcherScenarioTest.java similarity index 82% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotMatcherScenarioTest.java index 619cd3e..f612c2c 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherScenarioTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotMatcherScenarioTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -20,7 +20,7 @@ class SnapshotMatcherScenarioTest { private static final String FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotMatcherScenarioTest.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotMatcherScenarioTest.snap"; static SnapshotVerifier snapshotVerifier; @@ -36,10 +36,10 @@ static void afterAll() throws IOException { File f = new File(FILE_PATH); assertThat(String.join("\n", Files.readAllLines(f.toPath()))) .isEqualTo( - "au.com.origin.snapshots.SnapshotMatcherScenarioTest.should1ShowSnapshotSuccessfully[Scenario A]=[\n" + "io.github.finoid.snapshots.SnapshotMatcherScenarioTest.should1ShowSnapshotSuccessfully[Scenario A]=[\n" + "any type of object\n" + "]\n\n\n" - + "au.com.origin.snapshots.SnapshotMatcherScenarioTest.should2SecondSnapshotExecutionSuccessfully[Scenario B]=[\n" + + "io.github.finoid.snapshots.SnapshotMatcherScenarioTest.should2SecondSnapshotExecutionSuccessfully[Scenario B]=[\n" + "any second type of object\n" + "]"); Files.delete(Paths.get(FILE_PATH)); diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotMatcherTest.java similarity index 83% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotMatcherTest.java index 9cf5515..57d41ab 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotMatcherTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotMatcherTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ @ExtendWith(MockitoExtension.class) class SnapshotMatcherTest { private static final String FILE_PATH = - "src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotMatcherTest.snap"; + "src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotMatcherTest.snap"; static SnapshotVerifier snapshotVerifier; @BeforeAll @@ -33,10 +33,10 @@ static void afterAll() throws IOException { File f = new File(FILE_PATH); assertThat(String.join("\n", Files.readAllLines(f.toPath()))) .isEqualTo( - "au.com.origin.snapshots.SnapshotMatcherTest.should1ShowSnapshotSuccessfully=[\n" + "io.github.finoid.snapshots.SnapshotMatcherTest.should1ShowSnapshotSuccessfully=[\n" + "any type of object\n" + "]\n\n\n" - + "au.com.origin.snapshots.SnapshotMatcherTest.should2SecondSnapshotExecutionSuccessfully=[\n" + + "io.github.finoid.snapshots.SnapshotMatcherTest.should2SecondSnapshotExecutionSuccessfully=[\n" + "any second type of object\n" + "]"); Files.delete(Paths.get(FILE_PATH)); diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotNameAnnotationTest.java similarity index 94% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotNameAnnotationTest.java index 08c8600..f9e52c2 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotNameAnnotationTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.exceptions.ReservedWordException; +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.exceptions.ReservedWordException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java similarity index 68% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java index 1d70324..2bb9731 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotNameAnnotationWithDuplicatesTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotExtensionException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; @@ -17,7 +17,7 @@ void canUseSnapshotNameAnnotation(TestInfo testInfo) { SnapshotExtensionException.class, () -> new SnapshotVerifier(new BaseSnapshotConfig(), testInfo.getTestClass().get()), "Oops, looks like you set the same name of two separate snapshots @SnapshotName(\"hello_world\") in " - + "class au.com.origin.snapshots.SnapshotNameAnnotationTest"); + + "class io.github.finoid.snapshots.SnapshotNameAnnotationTest"); } @SnapshotName("hello_world") diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotOverrideClassTest.java similarity index 83% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotOverrideClassTest.java index 48e7544..bca77b1 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotOverrideClassTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotOverrideClassTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotSuperClassTest.java similarity index 92% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotSuperClassTest.java index 8a358c5..6f113bd 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotSuperClassTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotSuperClassTest.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; import lombok.Getter; import lombok.Setter; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotTest.java similarity index 67% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotTest.java index 092948a..66b9b93 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotTest.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; import org.junit.jupiter.api.Test; @@ -11,9 +11,9 @@ class SnapshotTest { public void shouldParseSnapshot() { Snapshot snapshot = Snapshot.parse( - Snapshot.builder().name("au.com.origin.snapshots.Test").body("body").build().raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + Snapshot.builder().name("io.github.finoid.snapshots.Test").body("body").build().raw()); + assertThat(snapshot.getIdentifier()).isEqualTo("io.github.finoid.snapshots.Test"); + assertThat(snapshot.getName()).isEqualTo("io.github.finoid.snapshots.Test"); assertThat(snapshot.getHeader()).isEmpty(); assertThat(snapshot.getScenario()).isBlank(); assertThat(snapshot.getBody()).isEqualTo("body"); @@ -26,13 +26,13 @@ public void shouldParseSnapshotWithHeaders() { Snapshot snapshot = Snapshot.parse( Snapshot.builder() - .name("au.com.origin.snapshots.Test") + .name("io.github.finoid.snapshots.Test") .header(header) .body("body") .build() .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getIdentifier()).isEqualTo("io.github.finoid.snapshots.Test"); + assertThat(snapshot.getName()).isEqualTo("io.github.finoid.snapshots.Test"); assertThat(snapshot.getHeader()).containsExactly(entry("header1", "value1")); assertThat(snapshot.getScenario()).isBlank(); assertThat(snapshot.getBody()).isEqualTo("body"); @@ -43,13 +43,13 @@ public void shouldParseSnapshotWithScenario() { Snapshot snapshot = Snapshot.parse( Snapshot.builder() - .name("au.com.origin.snapshots.Test") + .name("io.github.finoid.snapshots.Test") .scenario("scenario") .body("body") .build() .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getIdentifier()).isEqualTo("io.github.finoid.snapshots.Test[scenario]"); + assertThat(snapshot.getName()).isEqualTo("io.github.finoid.snapshots.Test"); assertThat(snapshot.getHeader()).isEmpty(); assertThat(snapshot.getScenario()).isEqualTo("scenario"); assertThat(snapshot.getBody()).isEqualTo("body"); @@ -62,14 +62,14 @@ public void shouldParseSnapshotWithScenarioAndHeaders() { Snapshot snapshot = Snapshot.parse( Snapshot.builder() - .name("au.com.origin.snapshots.Test") + .name("io.github.finoid.snapshots.Test") .scenario("scenario") .header(header) .body("body") .build() .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getIdentifier()).isEqualTo("io.github.finoid.snapshots.Test[scenario]"); + assertThat(snapshot.getName()).isEqualTo("io.github.finoid.snapshots.Test"); assertThat(snapshot.getHeader()).containsExactly(entry("header1", "value1")); assertThat(snapshot.getScenario()).isEqualTo("scenario"); assertThat(snapshot.getBody()).isEqualTo("body"); @@ -80,13 +80,13 @@ public void shouldParseSnapshotWithScenarioAndBodyWithSomethingSimilarToAnScenar Snapshot snapshot = Snapshot.parse( Snapshot.builder() - .name("au.com.origin.snapshots.Test") + .name("io.github.finoid.snapshots.Test") .scenario("scenario") .body("[xxx]=yyy") .build() .raw()); - assertThat(snapshot.getIdentifier()).isEqualTo("au.com.origin.snapshots.Test[scenario]"); - assertThat(snapshot.getName()).isEqualTo("au.com.origin.snapshots.Test"); + assertThat(snapshot.getIdentifier()).isEqualTo("io.github.finoid.snapshots.Test[scenario]"); + assertThat(snapshot.getName()).isEqualTo("io.github.finoid.snapshots.Test"); assertThat(snapshot.getHeader()).isEmpty(); assertThat(snapshot.getScenario()).isEqualTo("scenario"); assertThat(snapshot.getBody()).isEqualTo("[xxx]=yyy"); diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotUtils.java similarity index 92% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotUtils.java index d471685..80c1eae 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtils.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotUtils.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.apache.commons.io.FileUtils; @@ -100,8 +100,8 @@ private static Map>> process( public static void copyTestSnapshots() { try { FileUtils.copyDirectory( - Paths.get("src/test/java/au/com/origin/snapshots/existing-snapshots").toFile(), - Paths.get("src/test/java/au/com/origin/snapshots").toFile()); + Paths.get("src/test/java/io/github/finoid/snapshots/existing-snapshots").toFile(), + Paths.get("src/test/java/io/github/finoid/snapshots").toFile()); } catch (IOException e) { throw new RuntimeException("Can't move files to __snapshots__ folder"); } diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotUtilsTest.java similarity index 94% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotUtilsTest.java index 231f880..8078b3e 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/SnapshotUtilsTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/SnapshotUtilsTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.extension.ExtendWith; @@ -10,7 +10,7 @@ import java.util.Arrays; import java.util.List; -import static au.com.origin.snapshots.SnapshotUtils.extractArgs; +import static io.github.finoid.snapshots.SnapshotUtils.extractArgs; @ExtendWith(MockitoExtension.class) class SnapshotUtilsTest { diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UpdateSnapshotPropertyTest.java similarity index 76% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UpdateSnapshotPropertyTest.java index 91caacd..046dccc 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotPropertyTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UpdateSnapshotPropertyTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; @@ -33,14 +33,14 @@ static void afterAll() { public void beforeEach() throws Exception { File file = new File( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap"); + "src/test/java/io/github/finoid/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap"); String content = - "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" + "io.github.finoid.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" + "FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null)\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" + "FakeObject(id=ERROR, value=2, name=anyName2, fakeObject=null)\n" + "]"; Path parentDir = file.getParentFile().toPath(); @@ -63,16 +63,16 @@ void shouldUpdateSnapshot(TestInfo testInfo) throws IOException { new String( Files.readAllBytes( Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap")), + "src/test/java/io/github/finoid/snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap")), StandardCharsets.UTF_8); Assertions.assertThat(content) .isEqualTo( - "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" + "io.github.finoid.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[\n" + "FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null)\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[\n" + "FakeObject(id=anyId2, value=2, name=anyName2, fakeObject=null)\n" + "]"); } @@ -89,6 +89,6 @@ void shouldNotUpdateSnapshot(TestInfo testInfo) { expect.toMatchSnapshot( FakeObject.builder().id("anyId1").value(1).name("anyName1").build()), "Error on: \n" - + "au.com.origin.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=["); + + "io.github.finoid.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=["); } } diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UpdateSnapshotTest.java similarity index 75% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UpdateSnapshotTest.java index 1dd2a45..e182f7e 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UpdateSnapshotTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UpdateSnapshotTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -26,19 +26,19 @@ public class UpdateSnapshotTest { @BeforeEach public void beforeEach() throws Exception { File file = - new File("src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap"); + new File("src/test/java/io/github/finoid/snapshots/__snapshots__/UpdateSnapshotTest.snap"); String content = - "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + "OLD\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + "OLD\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + "OLD\n" + "]"; Path parentDir = file.getParentFile().toPath(); @@ -67,21 +67,21 @@ public Optional updateSnapshot() { new String( Files.readAllBytes( Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap")), + "src/test/java/io/github/finoid/snapshots/__snapshots__/UpdateSnapshotTest.snap")), StandardCharsets.UTF_8); Assertions.assertThat(content) .isEqualTo( - "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + "NEW\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + "OLD\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + "OLD\n" + "]"); } @@ -133,21 +133,21 @@ public Optional updateSnapshot() { new String( Files.readAllBytes( Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/UpdateSnapshotTest.snap")), + "src/test/java/io/github/finoid/snapshots/__snapshots__/UpdateSnapshotTest.snap")), StandardCharsets.UTF_8); Assertions.assertThat(content) .isEqualTo( - "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateAllSnapshots=[\n" + "OLD\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateClassNameSnapshots=[\n" + "NEW\n" + "]\n" + "\n" + "\n" - + "au.com.origin.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + + "io.github.finoid.snapshots.UpdateSnapshotTest.canUpdateNoSnapshots=[\n" + "OLD\n" + "]"); } diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UseCustomConfigTest.java similarity index 79% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UseCustomConfigTest.java index 82f2a07..2585772 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomConfigTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UseCustomConfigTest.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.config.ToStringSnapshotConfig; +import io.github.finoid.snapshots.annotations.UseSnapshotConfig; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.config.ToStringSnapshotConfig; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UseCustomSerializerTest.java similarity index 88% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UseCustomSerializerTest.java index 5ff4abb..60f131e 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/UseCustomSerializerTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/UseCustomSerializerTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.config.BaseSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.UppercaseToStringSerializer; +import io.github.finoid.snapshots.config.BaseSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.serializers.UppercaseToStringSerializer; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/comparators/PlainTextEqualsComparatorTest.java similarity index 90% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/comparators/PlainTextEqualsComparatorTest.java index 8e1b664..b61844e 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/comparators/PlainTextEqualsComparatorTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/comparators/PlainTextEqualsComparatorTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.comparators; +package io.github.finoid.snapshots.comparators; -import au.com.origin.snapshots.Snapshot; +import io.github.finoid.snapshots.Snapshot; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/config/BaseSnapshotConfig.java similarity index 62% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/config/BaseSnapshotConfig.java index 210a751..bb0d37f 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/BaseSnapshotConfig.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/config/BaseSnapshotConfig.java @@ -1,11 +1,11 @@ -package au.com.origin.snapshots.config; - -import au.com.origin.snapshots.comparators.PlainTextEqualsComparator; -import au.com.origin.snapshots.comparators.SnapshotComparator; -import au.com.origin.snapshots.reporters.PlainTextSnapshotReporter; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SnapshotSerializer; -import au.com.origin.snapshots.serializers.ToStringSnapshotSerializer; +package io.github.finoid.snapshots.config; + +import io.github.finoid.snapshots.comparators.PlainTextEqualsComparator; +import io.github.finoid.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.reporters.PlainTextSnapshotReporter; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.serializers.ToStringSnapshotSerializer; import java.util.Collections; import java.util.List; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/config/ToStringSnapshotConfig.java similarity index 64% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/config/ToStringSnapshotConfig.java index 5c06e67..42948f2 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/config/ToStringSnapshotConfig.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/config/ToStringSnapshotConfig.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.config; +package io.github.finoid.snapshots.config; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; public class ToStringSnapshotConfig extends BaseSnapshotConfig { diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap new file mode 100644 index 0000000..fcf576c --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotLineEndingsTest.snap @@ -0,0 +1,4 @@ +io.github.finoid.snapshots.DebugSnapshotLineEndingsTest.existingSnapshotDifferentLineEndings=[ +a +b +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap new file mode 100644 index 0000000..00c27a7 --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/DebugSnapshotTest.snap @@ -0,0 +1,13 @@ +io.github.finoid.snapshots.DebugSnapshotTest.createDebugFile=[ +Good Snapshot +] + + +io.github.finoid.snapshots.DebugSnapshotTest.debugFileCreatedSnapshotMatch=[ +Good Snapshot +] + + +io.github.finoid.snapshots.DebugSnapshotTest.debugFileCreatedExistingSnapshot=[ +Good Snapshot +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap similarity index 100% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap similarity index 100% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap new file mode 100644 index 0000000..00c27a7 --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap @@ -0,0 +1,13 @@ +io.github.finoid.snapshots.DebugSnapshotTest.createDebugFile=[ +Good Snapshot +] + + +io.github.finoid.snapshots.DebugSnapshotTest.debugFileCreatedSnapshotMatch=[ +Good Snapshot +] + + +io.github.finoid.snapshots.DebugSnapshotTest.debugFileCreatedExistingSnapshot=[ +Good Snapshot +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap similarity index 51% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap index d0aff78..88c8742 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/OrphanSnapshotTest.snap @@ -1,4 +1,4 @@ -au.com.origin.snapshots.OrphanSnapshotTest.orphanMethod=[ +io.github.finoid.snapshots.OrphanSnapshotTest.orphanMethod=[ { "message": "This orphan method should fail the test" } diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap new file mode 100644 index 0000000..fb4393e --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/PrivateCalledMethodTest.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.PrivateCalledMethodTest.testName=[ +testContent +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/README.md b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/README.md similarity index 100% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/README.md rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/README.md diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap new file mode 100644 index 0000000..8733f21 --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/ScenarioTest.snap @@ -0,0 +1,28 @@ +io.github.finoid.snapshots.ScenarioTest.canTakeMultipleSnapshotsUsingScenario=[ +Default Snapshot +] + + +io.github.finoid.snapshots.ScenarioTest.canTakeMultipleSnapshotsUsingScenario[additional]=[ +Additional Snapshot +] + + +io.github.finoid.snapshots.ScenarioTest.canTakeTheSameSnapshotTwice=[ +Default Snapshot +] + + +io.github.finoid.snapshots.ScenarioTest.canTakeTheSameSnapshotTwice[scenario]=[ +Scenario Snapshot +] + + +io.github.finoid.snapshots.ScenarioTest.cannotTakeDifferentSnapshotsAtDefaultLevel=[ +Default Snapshot +] + + +io.github.finoid.snapshots.ScenarioTest.cannotTakeDifferentSnapshotsAtScenarioLevel[scenario]=[ +Default Snapshot +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap new file mode 100644 index 0000000..bffe457 --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotHeaders.snap @@ -0,0 +1,10 @@ +io.github.finoid.snapshots.SnapshotHeaders.shouldBeAbleToSnapshotASingleCustomHeader={ + "custom": "anything", + "custom2": "anything2" +}hello world + + +io.github.finoid.snapshots.SnapshotHeaders.shouldBeAbleToSnapshotMultipleCustomHeader={ + "custom": "anything", + "custom2": "anything2" +}hello world \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap new file mode 100644 index 0000000..d048e0f --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotIntegrationTest.snap @@ -0,0 +1,37 @@ +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotFour=[ +FakeObject(id=anyId4, value=4, name=any +. +. +Name4, fakeObject=null) +] + + +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotInsidePrivateMethod=[ +FakeObject(id=anyPrivate, value=5, name=anyPrivate, fakeObject=null) +] + + +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotOne=[ +FakeObject(id=anyId1, value=1, name=anyName1, fakeObject=null) +] + + +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotThree=[ +FakeObject(id=anyId3, value=3, name=anyName3, fakeObject=null) +] + + +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldMatchSnapshotTwo=[ +FakeObject(id=anyId2, value=2, name=anyName2, fakeObject=null) +] + + +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldSnapshotUsingSerializerClass=HELLO WORLD + + +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldSnapshotUsingSerializerPropertyName=hello world + + +io.github.finoid.snapshots.SnapshotIntegrationTest.shouldThrowSnapshotMatchException=[ +FakeObject(id=anyId5, value=7, name=anyName5, fakeObject=null) +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap similarity index 100% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotNameAnnotationTest.snap diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap new file mode 100644 index 0000000..6db8f95 --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotOverrideClassTest.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.SnapshotOverrideClassTest.shouldMatchSnapshotOne=[ +anyName +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap similarity index 100% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/SnapshotUtilsTest.snap diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap new file mode 100644 index 0000000..42513dc --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UpdateSnapshotPropertyTest.snap @@ -0,0 +1,8 @@ +io.github.finoid.snapshots.UpdateSnapshotPropertyTest.shouldNotUpdateSnapshot=[ +FakeObject(id=ERROR, value=1, name=anyName1, fakeObject=null) +] + + +io.github.finoid.snapshots.UpdateSnapshotPropertyTest.shouldUpdateSnapshot=[ +FakeObject(id=ERROR, value=1, name=anyName2, fakeObject=null) +] \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap new file mode 100644 index 0000000..c343c13 --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomConfigTest.snap @@ -0,0 +1,4 @@ +io.github.finoid.snapshots.UseCustomConfigTest.canUseSnapshotConfigAnnotationAtClassLevel=This is a snapshot of the toString() method + + +io.github.finoid.snapshots.UseCustomConfigTest.canUseSnapshotConfigAnnotationAtMethodLevel=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap new file mode 100644 index 0000000..7ed515a --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/UseCustomSerializerTest.snap @@ -0,0 +1,10 @@ +io.github.finoid.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtClassLevel=this is a snapshot of the tostring() method + + +io.github.finoid.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtMethodLevel=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD + + +io.github.finoid.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtMethodLevelUsingClassName=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD + + +io.github.finoid.snapshots.UseCustomSerializerTest.canUseSnapshotSerializerAnnotationAtMethodLevelUsingNewInstance=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD \ No newline at end of file diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/reporters/PlainTextSnapshotReporterTest.java similarity index 89% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/reporters/PlainTextSnapshotReporterTest.java index bea19c6..62208c1 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/reporters/PlainTextSnapshotReporterTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/reporters/PlainTextSnapshotReporterTest.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.reporters; +package io.github.finoid.snapshots.reporters; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.serializers.SerializerType; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.opentest4j.AssertionFailedError; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/Base64SnapshotSerializerTest.java similarity index 96% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/Base64SnapshotSerializerTest.java index 27c2f68..f89a08e 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/Base64SnapshotSerializerTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/Base64SnapshotSerializerTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotHeader; -import au.com.origin.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotHeader; +import io.github.finoid.snapshots.SnapshotSerializerContext; import org.junit.jupiter.api.Test; import java.io.File; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/LowercaseToStringSerializer.java similarity index 68% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/LowercaseToStringSerializer.java index 326f52a..e3ee1e0 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/LowercaseToStringSerializer.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/LowercaseToStringSerializer.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; public class LowercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/ToStringSnapshotSerializerTest.java similarity index 93% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/ToStringSnapshotSerializerTest.java index 416b813..0dcf637 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializerTest.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/ToStringSnapshotSerializerTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotHeader; -import au.com.origin.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotHeader; +import io.github.finoid.snapshots.SnapshotSerializerContext; import lombok.AllArgsConstructor; import lombok.Data; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/UppercaseToStringSerializer.java similarity index 68% rename from snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/UppercaseToStringSerializer.java index b953de7..a569551 100644 --- a/snapshot-testing-core/src/test/java/au/com/origin/snapshots/serializers/UppercaseToStringSerializer.java +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/serializers/UppercaseToStringSerializer.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.serializers; +package io.github.finoid.snapshots.serializers; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; public class UppercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-core/src/test/resources/snapshot.properties b/snapshot-testing-core/src/test/resources/snapshot.properties index 31d4012..03ba77d 100644 --- a/snapshot-testing-core/src/test/resources/snapshot.properties +++ b/snapshot-testing-core/src/test/resources/snapshot.properties @@ -1 +1 @@ -serializer.lowercase=au.com.origin.snapshots.serializers.LowercaseToStringSerializer \ No newline at end of file +serializer.lowercase=io.github.finoid.snapshots.serializers.LowercaseToStringSerializer \ No newline at end of file diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java b/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java deleted file mode 100644 index 52cd065..0000000 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializer.java +++ /dev/null @@ -1,17 +0,0 @@ -package au.com.origin.snapshots.jackson.serializers; - -import au.com.origin.snapshots.logging.LoggingHelper; -import lombok.extern.slf4j.Slf4j; - -@Deprecated -@Slf4j -public class JacksonSnapshotSerializer - extends au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer { - - public JacksonSnapshotSerializer() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer` in `snapshot.properties`"); - } -} diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap deleted file mode 100644 index 22d9cec..0000000 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap +++ /dev/null @@ -1,5 +0,0 @@ -au.com.origin.snapshots.jackson.docs.CustomSerializerTest.test1=[ - { - "somethingElse": "This should render" - } -] \ No newline at end of file diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap deleted file mode 100644 index 8f171f3..0000000 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap +++ /dev/null @@ -1,140 +0,0 @@ -au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ - { - "aBoolean": true, - "aByte": 65, - "aChar": "A", - "aDouble": 1.123456789123456, - "aFloat": 0.1234567, - "aLong": 9223372036854775807, - "aShort": 32767, - "anEnum": "A", - "anEnumArray": [ - "F", - "A", - "D", - "E", - "G", - "B", - "C" - ], - "anInt": 2147483647, - "anObject": { }, - "arrayList": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "date": "2020-10-19T22:21:07.103+00:00", - "emptyOptional": null, - "hashMap": { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - "hashSet": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "linkedHashMap": { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - "linkedHashSet": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "linkedList": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "listOfCollections": [ - { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ] - ], - "localDate": "2020-10-19", - "localDateTime": "2020-10-19T22:21:07.103", - "presentOptional": "Hello World", - "string": "Hello World", - "stringArray": [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "treeMap": { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - "treeSet": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" - } -] \ No newline at end of file diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap deleted file mode 100644 index 715e791..0000000 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap +++ /dev/null @@ -1,140 +0,0 @@ -au.com.origin.snapshots.jackson.serializers.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ - { - "anObject": { }, - "aByte": 65, - "aShort": 32767, - "anInt": 2147483647, - "aLong": 9223372036854775807, - "aFloat": 0.1234567, - "aDouble": 1.123456789123456, - "aBoolean": true, - "aChar": "A", - "string": "Hello World", - "date": "2020-10-19T22:21:07.103+00:00", - "localDate": "2020-10-19", - "localDateTime": "2020-10-19T22:21:07.103", - "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]", - "anEnum": "A", - "presentOptional": "Hello World", - "emptyOptional": null, - "stringArray": [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "anEnumArray": [ - "F", - "A", - "D", - "E", - "G", - "B", - "C" - ], - "hashMap": { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - "treeMap": { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - "linkedHashMap": { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - "linkedHashSet": [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "hashSet": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "treeSet": [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "arrayList": [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "linkedList": [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "listOfCollections": [ - { - "a": 97, - "b": 98, - "c": 99, - "d": 100, - "e": 101, - "f": 102, - "g": 103 - }, - [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ] - ] - } -] \ No newline at end of file diff --git a/snapshot-testing-jackson/src/test/resources/snapshot.properties b/snapshot-testing-jackson/src/test/resources/snapshot.properties deleted file mode 100644 index 141beb8..0000000 --- a/snapshot-testing-jackson/src/test/resources/snapshot.properties +++ /dev/null @@ -1,8 +0,0 @@ -serializer=au.com.origin.snapshots.jackson.serializers.JacksonSnapshotSerializer -serializer.orderedJson=au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer -comparator=au.com.origin.snapshots.comparators.PlainTextEqualsComparator -reporters=au.com.origin.snapshots.reporters.PlainTextSnapshotReporter -snapshot-dir=__snapshots__ -output-dir=src/test/java -ci-env-var=CI -update-snapshot=none \ No newline at end of file diff --git a/snapshot-testing-jackson/pom.xml b/snapshot-testing-jackson2/pom.xml similarity index 97% rename from snapshot-testing-jackson/pom.xml rename to snapshot-testing-jackson2/pom.xml index dab2984..28c1e63 100644 --- a/snapshot-testing-jackson/pom.xml +++ b/snapshot-testing-jackson2/pom.xml @@ -10,8 +10,8 @@ ../pom.xml - snapshot-testing-jackson - finoid-snapshot-testing-jackson + snapshot-testing-jackson2 + finoid-snapshot-testing-jackson2 Jackson2 library for snapshot-testing diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicCollectionModule.java similarity index 97% rename from snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicCollectionModule.java index c4c4c8a..65145e9 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicCollectionModule.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicCollectionModule.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.jackson.serializers; +package io.github.finoid.snapshots.jackson.serializers; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java similarity index 58% rename from snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java index 36b6e27..65a3c82 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.jackson.serializers; +package io.github.finoid.snapshots.jackson.serializers; -import au.com.origin.snapshots.logging.LoggingHelper; +import io.github.finoid.snapshots.logging.LoggingHelper; import lombok.extern.slf4j.Slf4j; /** @@ -14,11 +14,11 @@ @Deprecated @Slf4j public class DeterministicJacksonSnapshotSerializer - extends au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer { + extends io.github.finoid.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer { public DeterministicJacksonSnapshotSerializer() { super(); LoggingHelper.deprecatedV5( log, - "Update to `au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer` in `snapshot.properties`"); + "Update to `v1.serializers.jackson.io.github.finoid.snapshots.DeterministicJacksonSnapshotSerializer` in `snapshot.properties`"); } } diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java new file mode 100644 index 0000000..42510e1 --- /dev/null +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java @@ -0,0 +1,17 @@ +package io.github.finoid.snapshots.jackson.serializers; + +import io.github.finoid.snapshots.logging.LoggingHelper; +import lombok.extern.slf4j.Slf4j; + +@Deprecated +@Slf4j +public class JacksonSnapshotSerializer + extends io.github.finoid.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer { + + public JacksonSnapshotSerializer() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `v1.serializers.jackson.io.github.finoid.snapshots.JacksonSnapshotSerializer` in `snapshot.properties`"); + } +} diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java similarity index 83% rename from snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java index b632ca3..6738b48 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.jackson.serializers.v1; +package io.github.finoid.snapshots.jackson.serializers.v1; -import au.com.origin.snapshots.jackson.serializers.DeterministicCollectionModule; +import io.github.finoid.snapshots.jackson.serializers.DeterministicCollectionModule; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java similarity index 88% rename from snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java index 5c4b9b8..09b0c71 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java @@ -1,10 +1,10 @@ -package au.com.origin.snapshots.jackson.serializers.v1; +package io.github.finoid.snapshots.jackson.serializers.v1; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.exceptions.SnapshotExtensionException; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.PrettyPrinter; diff --git a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java similarity index 93% rename from snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java index a11db6f..081acc5 100644 --- a/snapshot-testing-jackson/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.jackson.serializers.v1; +package io.github.finoid.snapshots.jackson.serializers.v1; import com.fasterxml.jackson.core.util.DefaultIndenter; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/NoNameChangeTest.java similarity index 54% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/NoNameChangeTest.java index b66c03c..88a1548 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/NoNameChangeTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/NoNameChangeTest.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.jackson; +package io.github.finoid.snapshots.jackson; -import au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; -import au.com.origin.snapshots.jackson.serializers.JacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializer; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -16,9 +16,9 @@ public class NoNameChangeTest { @Test public void serializersApiShouldNotChange() { assertThat(JacksonSnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.jackson.serializers.JacksonSnapshotSerializer"); + .isEqualTo("io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializer"); assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) .isEqualTo( - "au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer"); + "io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer"); } } diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/ReflectionUtilities.java similarity index 91% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/ReflectionUtilities.java index 3c2b037..885be51 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/ReflectionUtilities.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/ReflectionUtilities.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.jackson3; +package io.github.finoid.snapshots.jackson; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import java.lang.reflect.Method; import java.util.Optional; diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/BaseEntity.java similarity index 86% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/BaseEntity.java index e17cc99..26465b9 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/BaseEntity.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/BaseEntity.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson.docs; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/CustomSerializerTest.java similarity index 75% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/CustomSerializerTest.java index fa3fc03..0b578a5 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/CustomSerializerTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/CustomSerializerTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/HibernateSnapshotSerializer.java similarity index 88% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/HibernateSnapshotSerializer.java index 6deb226..bdafb8b 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/HibernateSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/HibernateSnapshotSerializer.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson.docs; -import au.com.origin.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreType; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonAssertReporter.java similarity index 71% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonAssertReporter.java index 8441a62..ae0116a 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonAssertReporter.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonAssertReporter.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.SerializerType; import lombok.SneakyThrows; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonObjectComparator.java similarity index 78% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonObjectComparator.java index a055e4b..d5619fd 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/docs/JsonObjectComparator.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonObjectComparator.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.comparators.SnapshotComparator; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.SneakyThrows; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap new file mode 100644 index 0000000..10a6138 --- /dev/null +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap @@ -0,0 +1,12 @@ +docs.jackson.io.github.finoid.snapshots.CustomSerializerTest.test1=[ + { + "somethingElse": "This should render" + } +] + + +io.github.finoid.snapshots.jackson.docs.CustomSerializerTest.test1=[ + { + "somethingElse": "This should render" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java similarity index 95% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java index 9ac738a..ae8c2d3 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.jackson3.serializers.v1; +package io.github.finoid.snapshots.jackson.serializers; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.serializers.SerializerType; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java similarity index 91% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java index a877e80..9b7ca3b 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java @@ -1,14 +1,14 @@ -package au.com.origin.snapshots.jackson.serializers; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotHeader; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +package io.github.finoid.snapshots.jackson.serializers; + +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotHeader; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap new file mode 100644 index 0000000..3c1757b --- /dev/null +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap @@ -0,0 +1,282 @@ +io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean": true, + "aByte": 65, + "aChar": "A", + "aDouble": 1.123456789123456, + "aFloat": 0.1234567, + "aLong": 9223372036854775807, + "aShort": 32767, + "anEnum": "A", + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt": 2147483647, + "anObject": { }, + "arrayList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date": "2020-10-19T22:21:07.103+00:00", + "emptyOptional": null, + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "presentOptional": "Hello World", + "string": "Hello World", + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] + + +serializers.jackson.io.github.finoid.snapshots.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean": true, + "aByte": 65, + "aChar": "A", + "aDouble": 1.123456789123456, + "aFloat": 0.1234567, + "aLong": 9223372036854775807, + "aShort": 32767, + "anEnum": "A", + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt": 2147483647, + "anObject": { }, + "arrayList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date": "2020-10-19T22:21:07.103+00:00", + "emptyOptional": null, + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "presentOptional": "Hello World", + "string": "Hello World", + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap new file mode 100644 index 0000000..62cd765 --- /dev/null +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap @@ -0,0 +1,282 @@ +io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "anObject": { }, + "aByte": 65, + "aShort": 32767, + "anInt": 2147483647, + "aLong": 9223372036854775807, + "aFloat": 0.1234567, + "aDouble": 1.123456789123456, + "aBoolean": true, + "aChar": "A", + "string": "Hello World", + "date": "2020-10-19T22:21:07.103+00:00", + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]", + "anEnum": "A", + "presentOptional": "Hello World", + "emptyOptional": null, + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "arrayList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ] + } +] + + +serializers.jackson.io.github.finoid.snapshots.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "anObject": { }, + "aByte": 65, + "aShort": 32767, + "anInt": 2147483647, + "aLong": 9223372036854775807, + "aFloat": 0.1234567, + "aDouble": 1.123456789123456, + "aBoolean": true, + "aChar": "A", + "string": "Hello World", + "date": "2020-10-19T22:21:07.103+00:00", + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]", + "anEnum": "A", + "presentOptional": "Hello World", + "emptyOptional": null, + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "arrayList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ] + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson2/src/test/resources/snapshot.properties b/snapshot-testing-jackson2/src/test/resources/snapshot.properties new file mode 100644 index 0000000..4a2666e --- /dev/null +++ b/snapshot-testing-jackson2/src/test/resources/snapshot.properties @@ -0,0 +1,8 @@ +serializer=io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializer +serializer.orderedJson=io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer +comparator=io.github.finoid.snapshots.comparators.PlainTextEqualsComparator +reporters=io.github.finoid.snapshots.reporters.PlainTextSnapshotReporter +snapshot-dir=__snapshots__ +output-dir=src/test/java +ci-env-var=CI +update-snapshot=none \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java similarity index 97% rename from snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java rename to snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java index dba837b..3136d93 100644 --- a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java +++ b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicCollectionModule.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.jackson3.serializers.v1; +package io.github.finoid.snapshots.jackson3.serializers.v1; import lombok.extern.slf4j.Slf4j; import tools.jackson.core.JacksonException; diff --git a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java similarity index 92% rename from snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java index 1dfa4d6..7fb4566 100644 --- a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializer.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.jackson3.serializers.v1; +package io.github.finoid.snapshots.jackson3.serializers.v1; import tools.jackson.databind.MapperFeature; import tools.jackson.databind.json.JsonMapper; diff --git a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java similarity index 90% rename from snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java rename to snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java index ed4897f..48286a6 100644 --- a/snapshot-testing-jackson3/src/main/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java @@ -1,10 +1,10 @@ -package au.com.origin.snapshots.jackson3.serializers.v1; +package io.github.finoid.snapshots.jackson3.serializers.v1; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.exceptions.SnapshotExtensionException; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.exceptions.SnapshotExtensionException; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonInclude; import tools.jackson.core.util.DefaultIndenter; diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap deleted file mode 100644 index 84dc2ac..0000000 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap +++ /dev/null @@ -1,5 +0,0 @@ -au.com.origin.snapshots.jackson3.docs.CustomSerializerTest.test1=[ - { - "somethingElse" : "This should render" - } -] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap deleted file mode 100644 index e785b8f..0000000 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap +++ /dev/null @@ -1,140 +0,0 @@ -au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ - { - "aBoolean" : true, - "aByte" : 65, - "aChar" : "A", - "aDouble" : 1.123456789123456, - "aFloat" : 0.1234567, - "aLong" : 9223372036854775807, - "aShort" : 32767, - "anEnum" : "A", - "anEnumArray" : [ - "F", - "A", - "D", - "E", - "G", - "B", - "C" - ], - "anInt" : 2147483647, - "anObject" : { }, - "arrayList" : [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "date" : "2020-10-19T22:21:07.103Z", - "emptyOptional" : null, - "hashMap" : { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - "hashSet" : [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "linkedHashMap" : { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - "linkedHashSet" : [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "linkedList" : [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "listOfCollections" : [ - { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ] - ], - "localDate" : "2020-10-19", - "localDateTime" : "2020-10-19T22:21:07.103", - "presentOptional" : "Hello World", - "string" : "Hello World", - "stringArray" : [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "treeMap" : { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - "treeSet" : [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" - } -] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap deleted file mode 100644 index 4cbc79b..0000000 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap +++ /dev/null @@ -1,140 +0,0 @@ -au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ - { - "aBoolean" : true, - "aByte" : 65, - "aChar" : "A", - "aDouble" : 1.123456789123456, - "aFloat" : 0.1234567, - "aLong" : 9223372036854775807, - "aShort" : 32767, - "anEnum" : "A", - "anEnumArray" : [ - "F", - "A", - "D", - "E", - "G", - "B", - "C" - ], - "anInt" : 2147483647, - "anObject" : { }, - "arrayList" : [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "date" : "2020-10-19T22:21:07.103Z", - "emptyOptional" : null, - "hashMap" : { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - "hashSet" : [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "linkedHashMap" : { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - "linkedHashSet" : [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "linkedList" : [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "listOfCollections" : [ - { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ] - ], - "localDate" : "2020-10-19", - "localDateTime" : "2020-10-19T22:21:07.103", - "presentOptional" : "Hello World", - "string" : "Hello World", - "stringArray" : [ - "f", - "a", - "d", - "e", - "g", - "b", - "c" - ], - "treeMap" : { - "a" : 97, - "b" : 98, - "c" : 99, - "d" : 100, - "e" : 101, - "f" : 102, - "g" : 103 - }, - "treeSet" : [ - "a", - "b", - "c", - "d", - "e", - "f", - "g" - ], - "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" - } -] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/NoNameChangeTest.java similarity index 53% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/NoNameChangeTest.java index 788b0b7..0138c4c 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/NoNameChangeTest.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/NoNameChangeTest.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.jackson3; +package io.github.finoid.snapshots.jackson3; -import au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer; -import au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -16,9 +16,9 @@ public class NoNameChangeTest { @Test public void serializersApiShouldNotChange() { assertThat(JacksonSnapshotSerializer.class.getName()) - .isEqualTo("au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer"); + .isEqualTo("io.github.finoid.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer"); assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) .isEqualTo( - "au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer"); + "io.github.finoid.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer"); } } diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/ReflectionUtilities.java similarity index 91% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/ReflectionUtilities.java index 374ba93..42f66eb 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/ReflectionUtilities.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/ReflectionUtilities.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.jackson; +package io.github.finoid.snapshots.jackson3; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; import java.lang.reflect.Method; import java.util.Optional; diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/BaseEntity.java similarity index 86% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/BaseEntity.java index 9b9c8f0..7ca974e 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/BaseEntity.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/BaseEntity.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.jackson3.docs; +package io.github.finoid.snapshots.jackson3.docs; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/CustomSerializerTest.java similarity index 75% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/CustomSerializerTest.java index d41298e..bd0caee 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/CustomSerializerTest.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/CustomSerializerTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.jackson3.docs; +package io.github.finoid.snapshots.jackson3.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/HibernateSnapshotSerializer.java similarity index 87% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/HibernateSnapshotSerializer.java index b8c7144..407b453 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/HibernateSnapshotSerializer.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/HibernateSnapshotSerializer.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots.jackson3.docs; +package io.github.finoid.snapshots.jackson3.docs; -import au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreType; import tools.jackson.databind.json.JsonMapper; diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/JsonAssertReporter.java similarity index 71% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/JsonAssertReporter.java index 9c13d2d..8c333ff 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonAssertReporter.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/JsonAssertReporter.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.jackson3.docs; +package io.github.finoid.snapshots.jackson3.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.reporters.SnapshotReporter; -import au.com.origin.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.reporters.SnapshotReporter; +import io.github.finoid.snapshots.serializers.SerializerType; import lombok.SneakyThrows; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/JsonObjectComparator.java similarity index 77% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/JsonObjectComparator.java index 996fd6b..effe592 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/docs/JsonObjectComparator.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/JsonObjectComparator.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.jackson3.docs; +package io.github.finoid.snapshots.jackson3.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.comparators.SnapshotComparator; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.comparators.SnapshotComparator; import lombok.SneakyThrows; import tools.jackson.databind.json.JsonMapper; diff --git a/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap new file mode 100644 index 0000000..bc6e0e4 --- /dev/null +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap @@ -0,0 +1,12 @@ +docs.jackson3.io.github.finoid.snapshots.CustomSerializerTest.test1=[ + { + "somethingElse" : "This should render" + } +] + + +io.github.finoid.snapshots.jackson3.docs.CustomSerializerTest.test1=[ + { + "somethingElse" : "This should render" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java similarity index 94% rename from snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java index 1a25b4b..834d958 100644 --- a/snapshot-testing-jackson/src/test/java/au/com/origin/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/DeterministicJacksonSnapshotSerializerTest.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.jackson.serializers; +package io.github.finoid.snapshots.jackson3.serializers.v1; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.serializers.SerializerType; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java similarity index 91% rename from snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java index cdf3bba..4319301 100644 --- a/snapshot-testing-jackson3/src/test/java/au/com/origin/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializerTest.java @@ -1,14 +1,14 @@ -package au.com.origin.snapshots.jackson3.serializers.v1; - -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotHeader; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +package io.github.finoid.snapshots.jackson3.serializers.v1; + +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotHeader; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; diff --git a/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap new file mode 100644 index 0000000..e35c382 --- /dev/null +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap @@ -0,0 +1,282 @@ +io.github.finoid.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] + + +v1.serializers.jackson3.io.github.finoid.snapshots.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap new file mode 100644 index 0000000..c75264a --- /dev/null +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap @@ -0,0 +1,282 @@ +io.github.finoid.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] + + +v1.serializers.jackson3.io.github.finoid.snapshots.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/resources/snapshot.properties b/snapshot-testing-jackson3/src/test/resources/snapshot.properties index 0ba48cb..74c96d2 100644 --- a/snapshot-testing-jackson3/src/test/resources/snapshot.properties +++ b/snapshot-testing-jackson3/src/test/resources/snapshot.properties @@ -1,7 +1,7 @@ -serializer=au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer -serializer.orderedJson=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer -comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator -reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter +serializer=io.github.finoid.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer +serializer.orderedJson=io.github.finoid.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer +comparator=io.github.finoid.snapshots.comparators.v1.PlainTextEqualsComparator +reporters=io.github.finoid.snapshots.reporters.v1.PlainTextSnapshotReporter snapshot-dir=__snapshots__ output-dir=src/test/java ci-env-var=CI diff --git a/snapshot-testing-junit5/pom.xml b/snapshot-testing-junit5/pom.xml index a4caa29..2c8b343 100644 --- a/snapshot-testing-junit5/pom.xml +++ b/snapshot-testing-junit5/pom.xml @@ -29,7 +29,7 @@ io.github.finoid - snapshot-testing-jackson + snapshot-testing-jackson2 org.checkerframework diff --git a/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java b/snapshot-testing-junit5/src/main/java/io/github/finoid/snapshots/junit5/SnapshotExtension.java similarity index 89% rename from snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java rename to snapshot-testing-junit5/src/main/java/io/github/finoid/snapshots/junit5/SnapshotExtension.java index d3e05b5..22a9179 100644 --- a/snapshot-testing-junit6/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java +++ b/snapshot-testing-junit5/src/main/java/io/github/finoid/snapshots/junit5/SnapshotExtension.java @@ -1,13 +1,13 @@ -package au.com.origin.snapshots.junit5; +package io.github.finoid.snapshots.junit5; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfigInjector; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.logging.LoggingHelper; -import au.com.origin.snapshots.utils.ReflectionUtils; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfigInjector; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.logging.LoggingHelper; +import io.github.finoid.snapshots.utils.ReflectionUtils; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; @@ -22,7 +22,7 @@ import java.lang.reflect.Field; @Slf4j -@SuppressWarnings({"checkstyle:all", "EmptyBlockTag"}) // TODO (nw) rewrite +@SuppressWarnings({"checkstyle:all", "EmptyBlockTag", "NullAway"}) // TODO (nw) rewrite public class SnapshotExtension implements AfterAllCallback, BeforeAllCallback, diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap deleted file mode 100644 index a659739..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.BaseClassTest$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap deleted file mode 100644 index b8d8953..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTest$NestedClassWithoutSnapshot.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap deleted file mode 100644 index b9bf45e..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap deleted file mode 100644 index 09fb8b1..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap +++ /dev/null @@ -1,28 +0,0 @@ -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtension=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ -Hello World -] - - -hello_world=[ -Hello World -] - - -hello_world_2=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap deleted file mode 100644 index a632d11..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap +++ /dev/null @@ -1,38 +0,0 @@ -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest=[ -Duplicates are OK -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ -Duplicates are OK -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ - "test input 1" -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ - "test input 2" -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ - "test input 1" -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ - "test input 2" -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap deleted file mode 100644 index 2438c51..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap deleted file mode 100644 index ed598d1..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap +++ /dev/null @@ -1 +0,0 @@ -au.com.origin.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap deleted file mode 100644 index ed598d1..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap +++ /dev/null @@ -1 +0,0 @@ -au.com.origin.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap deleted file mode 100644 index 7273361..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap +++ /dev/null @@ -1,8 +0,0 @@ -au.com.origin.snapshots.docs.JUnit5Example.myTest1=[ -Hello World -] - - -au.com.origin.snapshots.docs.JUnit5Example.myTest2=[ -Hello World Again -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap deleted file mode 100644 index b48f7c3..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap +++ /dev/null @@ -1,9 +0,0 @@ -au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ - { } -] - - -au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD - - -au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap deleted file mode 100644 index 1987c84..0000000 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap +++ /dev/null @@ -1,11 +0,0 @@ -au.com.origin.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ - { - "age": 40, - "name": "John Doe" - } -] - - -i_can_give_custom_names_to_my_snapshots=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/BaseClassTest.java similarity index 82% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/BaseClassTest.java index 5647c54..ab7eeb1 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/BaseClassTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/BaseClassTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTest.java similarity index 84% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTest.java index c0df8cb..cdf3841 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ public class NestedClassTest { @AfterAll public static void afterAll() { Path path = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest.snap"); + Paths.get("src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest.snap"); assertThat(Files.exists(path)).isFalse(); } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java similarity index 79% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java index 87c85e9..529ba50 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ public class NestedClassTestWithExtends { public static void afterAll() { Path path = Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); + "src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); assertThat(Files.exists(path)).isFalse(); } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java similarity index 85% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java index d8eb3ec..1858418 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java similarity index 83% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java index 09729fb..633fbea 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -25,7 +25,7 @@ static Stream testData() { } @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { expect.toMatchSnapshot("Duplicates are OK"); expect.toMatchSnapshot("Duplicates are OK"); @@ -37,7 +37,7 @@ void shouldSupportParameterizedTest(String scenario, String testInput, Expect ex } @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { this.expect.toMatchSnapshot("Duplicates are OK"); this.expect.toMatchSnapshot("Duplicates are OK"); diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap new file mode 100644 index 0000000..447eb87 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.BaseClassTest$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap new file mode 100644 index 0000000..1596b3f --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.NestedClassTest$NestedClassWithExpectInstance.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap new file mode 100644 index 0000000..bee72b5 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.NestedClassTest$NestedClassWithoutSnapshot.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap new file mode 100644 index 0000000..aca84ab --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap new file mode 100644 index 0000000..dc6a684 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap @@ -0,0 +1,28 @@ +hello_world=[ +Hello World +] + + +hello_world_2=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtension=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap new file mode 100644 index 0000000..22e22ee --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap @@ -0,0 +1,38 @@ +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ + "test input 2" +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ + "test input 2" +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java similarity index 78% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java index 19842d9..5d4346c 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java similarity index 65% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java index 28ce52e..88e870c 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.annotations.UseSnapshotConfig; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java similarity index 80% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java index b2593ce..996af0e 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java similarity index 80% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java index bd0be20..04e9af3 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.annotations.UseSnapshotConfig; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java similarity index 55% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java index 5c83846..1c64f2f 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; public class LowercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java similarity index 53% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java index 8f9aced..3ad9abe 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; public class LowercaseToStringSnapshotConfig extends PropertyResolvingSnapshotConfig { diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java similarity index 76% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java index 64782b6..5e9d2f5 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/TestObject.java similarity index 77% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/TestObject.java index f7a09ab..75fa794 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/TestObject.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/TestObject.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; public class TestObject { @Override diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java similarity index 55% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java index 9ca5f08..ecdbc53 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; public class UppercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap new file mode 100644 index 0000000..b06eefa --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap new file mode 100644 index 0000000..881d543 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap @@ -0,0 +1 @@ +io.github.finoid.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap new file mode 100644 index 0000000..e69de29 diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap new file mode 100644 index 0000000..752e9e9 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap @@ -0,0 +1,8 @@ +io.github.finoid.snapshots.docs.JUnit5Example.myTest1=[ +Hello World +] + + +io.github.finoid.snapshots.docs.JUnit5Example.myTest2=[ +Hello World Again +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap new file mode 100644 index 0000000..002cec4 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap @@ -0,0 +1,9 @@ +io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ + { } +] + + +io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD + + +io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap new file mode 100644 index 0000000..e69de29 diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap similarity index 58% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap index 1987c84..c0fccd4 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap @@ -1,11 +1,11 @@ -au.com.origin.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ +i_can_give_custom_names_to_my_snapshots=[ +Hello World +] + + +io.github.finoid.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ { "age": 40, "name": "John Doe" } -] - - -i_can_give_custom_names_to_my_snapshots=[ -Hello World ] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/resources/snapshot.properties b/snapshot-testing-junit5/src/test/resources/snapshot.properties index ca78343..b62c9bd 100644 --- a/snapshot-testing-junit5/src/test/resources/snapshot.properties +++ b/snapshot-testing-junit5/src/test/resources/snapshot.properties @@ -1,7 +1,7 @@ -serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer -serializer.json=au.com.origin.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer -comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator -reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter +serializer=io.github.finoid.snapshots.serializers.v1.ToStringSnapshotSerializer +serializer.json=io.github.finoid.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer +comparator=io.github.finoid.snapshots.comparators.v1.PlainTextEqualsComparator +reporters=io.github.finoid.snapshots.reporters.v1.PlainTextSnapshotReporter snapshot-dir=__snapshots__ output-dir=src/test/java ci-env-var=CI diff --git a/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java b/snapshot-testing-junit6/src/main/java/io/github/finoid/snapshots/junit5/SnapshotExtension.java similarity index 89% rename from snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java rename to snapshot-testing-junit6/src/main/java/io/github/finoid/snapshots/junit5/SnapshotExtension.java index d3e05b5..22a9179 100644 --- a/snapshot-testing-junit5/src/main/java/au/com/origin/snapshots/junit5/SnapshotExtension.java +++ b/snapshot-testing-junit6/src/main/java/io/github/finoid/snapshots/junit5/SnapshotExtension.java @@ -1,13 +1,13 @@ -package au.com.origin.snapshots.junit5; +package io.github.finoid.snapshots.junit5; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfig; -import au.com.origin.snapshots.config.SnapshotConfigInjector; -import au.com.origin.snapshots.exceptions.SnapshotMatchException; -import au.com.origin.snapshots.logging.LoggingHelper; -import au.com.origin.snapshots.utils.ReflectionUtils; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfig; +import io.github.finoid.snapshots.config.SnapshotConfigInjector; +import io.github.finoid.snapshots.exceptions.SnapshotMatchException; +import io.github.finoid.snapshots.logging.LoggingHelper; +import io.github.finoid.snapshots.utils.ReflectionUtils; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; @@ -22,7 +22,7 @@ import java.lang.reflect.Field; @Slf4j -@SuppressWarnings({"checkstyle:all", "EmptyBlockTag"}) // TODO (nw) rewrite +@SuppressWarnings({"checkstyle:all", "EmptyBlockTag", "NullAway"}) // TODO (nw) rewrite public class SnapshotExtension implements AfterAllCallback, BeforeAllCallback, diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap deleted file mode 100644 index a659739..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/BaseClassTest$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.BaseClassTest$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap deleted file mode 100644 index b8d8953..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTest$NestedClassWithoutSnapshot.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap deleted file mode 100644 index b9bf45e..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap deleted file mode 100644 index 09fb8b1..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap +++ /dev/null @@ -1,28 +0,0 @@ -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtension=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ -Hello World -] - - -au.com.origin.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ -Hello World -] - - -hello_world=[ -Hello World -] - - -hello_world_2=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap deleted file mode 100644 index a632d11..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/__snapshots__/SnapshotParameterTest.snap +++ /dev/null @@ -1,38 +0,0 @@ -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest=[ -Duplicates are OK -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ -Duplicates are OK -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ - "test input 1" -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ - "test input 2" -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ - "test input 1" -] - - -au.com.origin.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ - "test input 2" -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap deleted file mode 100644 index 2438c51..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomFrameworkExample.snap +++ /dev/null @@ -1,3 +0,0 @@ -au.com.origin.snapshots.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap deleted file mode 100644 index ed598d1..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap +++ /dev/null @@ -1 +0,0 @@ -au.com.origin.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap deleted file mode 100644 index ed598d1..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap +++ /dev/null @@ -1 +0,0 @@ -au.com.origin.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap deleted file mode 100644 index 7273361..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5Example.snap +++ /dev/null @@ -1,8 +0,0 @@ -au.com.origin.snapshots.docs.JUnit5Example.myTest1=[ -Hello World -] - - -au.com.origin.snapshots.docs.JUnit5Example.myTest2=[ -Hello World Again -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap deleted file mode 100644 index b48f7c3..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap +++ /dev/null @@ -1,9 +0,0 @@ -au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ - { } -] - - -au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD - - -au.com.origin.snapshots.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap deleted file mode 100644 index 1987c84..0000000 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap +++ /dev/null @@ -1,11 +0,0 @@ -au.com.origin.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ - { - "age": 40, - "name": "John Doe" - } -] - - -i_can_give_custom_names_to_my_snapshots=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/BaseClassTest.java similarity index 82% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/BaseClassTest.java index 5647c54..ab7eeb1 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/BaseClassTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/BaseClassTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTest.java similarity index 84% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTest.java index d770ee3..c6e951a 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTest.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ public class NestedClassTest { @AfterAll public static void afterAll() { Path path = - Paths.get("src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTest.snap"); + Paths.get("src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest.snap"); assertThat(Files.exists(path)).isFalse(); } diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java similarity index 79% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java index 87c85e9..529ba50 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/NestedClassTestWithExtends.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java @@ -1,6 +1,6 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ public class NestedClassTestWithExtends { public static void afterAll() { Path path = Paths.get( - "src/test/java/au/com/origin/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); + "src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends.snap"); assertThat(Files.exists(path)).isFalse(); } diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java similarity index 85% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java index d8eb3ec..1858418 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotExtensionUsedTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java similarity index 83% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java index 3bd1d9d..4ac7a77 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/SnapshotParameterTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots; +package io.github.finoid.snapshots; -import au.com.origin.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -25,7 +25,7 @@ static Stream testData() { } @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { expect.toMatchSnapshot("Duplicates are OK"); expect.toMatchSnapshot("Duplicates are OK"); @@ -37,7 +37,7 @@ void shouldSupportParameterizedTest(String scenario, String testInput, Expect ex } @ParameterizedTest - @MethodSource("au.com.origin.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { this.expect.toMatchSnapshot("Duplicates are OK"); this.expect.toMatchSnapshot("Duplicates are OK"); diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap new file mode 100644 index 0000000..447eb87 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.BaseClassTest$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap new file mode 100644 index 0000000..e69de29 diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap new file mode 100644 index 0000000..aca84ab --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap new file mode 100644 index 0000000..dc6a684 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap @@ -0,0 +1,28 @@ +hello_world=[ +Hello World +] + + +hello_world_2=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtension=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ +Hello World +] + + +io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap new file mode 100644 index 0000000..22e22ee --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap @@ -0,0 +1,38 @@ +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ + "test input 2" +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ + "test input 2" +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java similarity index 78% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java index 19842d9..5d4346c 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomFrameworkExample.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.SnapshotVerifier; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.SnapshotVerifier; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java similarity index 65% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java index 28ce52e..88e870c 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/CustomSnapshotConfigExample.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.annotations.UseSnapshotConfig; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java similarity index 80% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java index b2593ce..996af0e 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/JUnit5Example.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java similarity index 80% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java index bd0be20..04e9af3 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/JUnit5ResolutionHierarchyExample.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.UseSnapshotConfig; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.annotations.UseSnapshotConfig; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java similarity index 55% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java index 5c83846..1c64f2f 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; public class LowercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java similarity index 53% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java index 8f9aced..3ad9abe 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/LowercaseToStringSnapshotConfig.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java @@ -1,7 +1,7 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.config.PropertyResolvingSnapshotConfig; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; public class LowercaseToStringSnapshotConfig extends PropertyResolvingSnapshotConfig { diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java similarity index 76% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java index 64782b6..5e9d2f5 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/MyFirstSnapshotTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java @@ -1,8 +1,8 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Expect; -import au.com.origin.snapshots.annotations.SnapshotName; -import au.com.origin.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.annotations.SnapshotName; +import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/TestObject.java similarity index 77% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/TestObject.java index f7a09ab..75fa794 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/TestObject.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/TestObject.java @@ -1,4 +1,4 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; public class TestObject { @Override diff --git a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java similarity index 55% rename from snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java index 9ca5f08..ecdbc53 100644 --- a/snapshot-testing-junit5/src/test/java/au/com/origin/snapshots/docs/UppercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java @@ -1,9 +1,9 @@ -package au.com.origin.snapshots.docs; +package io.github.finoid.snapshots.docs; -import au.com.origin.snapshots.Snapshot; -import au.com.origin.snapshots.SnapshotSerializerContext; -import au.com.origin.snapshots.serializers.SerializerType; -import au.com.origin.snapshots.serializers.SnapshotSerializer; +import io.github.finoid.snapshots.Snapshot; +import io.github.finoid.snapshots.SnapshotSerializerContext; +import io.github.finoid.snapshots.serializers.SerializerType; +import io.github.finoid.snapshots.serializers.SnapshotSerializer; public class UppercaseToStringSerializer implements SnapshotSerializer { @Override diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap new file mode 100644 index 0000000..b06eefa --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap new file mode 100644 index 0000000..881d543 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap @@ -0,0 +1 @@ +io.github.finoid.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap new file mode 100644 index 0000000..e69de29 diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap new file mode 100644 index 0000000..752e9e9 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap @@ -0,0 +1,8 @@ +io.github.finoid.snapshots.docs.JUnit5Example.myTest1=[ +Hello World +] + + +io.github.finoid.snapshots.docs.JUnit5Example.myTest2=[ +Hello World Again +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap new file mode 100644 index 0000000..002cec4 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap @@ -0,0 +1,9 @@ +io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ + { } +] + + +io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD + + +io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap new file mode 100644 index 0000000..e69de29 diff --git a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap similarity index 58% rename from snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap index 568a7d0..fe0ada9 100644 --- a/snapshot-testing-junit6/src/test/java/au/com/origin/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap @@ -1,11 +1,11 @@ -au.com.origin.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ +i_can_give_custom_names_to_my_snapshots=[ +Hello World +] + + +io.github.finoid.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ { "age" : 40, "name" : "John Doe" } -] - - -i_can_give_custom_names_to_my_snapshots=[ -Hello World ] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/resources/snapshot.properties b/snapshot-testing-junit6/src/test/resources/snapshot.properties index 96a861e..ee68d50 100644 --- a/snapshot-testing-junit6/src/test/resources/snapshot.properties +++ b/snapshot-testing-junit6/src/test/resources/snapshot.properties @@ -1,7 +1,7 @@ -serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer -serializer.json=au.com.origin.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer -comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator -reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter +serializer=io.github.finoid.snapshots.serializers.v1.ToStringSnapshotSerializer +serializer.json=io.github.finoid.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializer +comparator=io.github.finoid.snapshots.comparators.v1.PlainTextEqualsComparator +reporters=io.github.finoid.snapshots.reporters.v1.PlainTextSnapshotReporter snapshot-dir=__snapshots__ output-dir=src/test/java ci-env-var=CI From 250b6fc84d1a9b5cb4190aed24121577e0ddc673 Mon Sep 17 00:00:00 2001 From: Nicklas Wallgren Date: Sun, 25 Jan 2026 15:02:12 +0100 Subject: [PATCH 9/9] chore: add github workflow --- .github/dependabot.yml | 8 + .github/workflows/dependabot-auto-merge.yml | 41 +++++ .github/workflows/publish.yml | 62 ++++++++ .github/workflows/verify.yml | 29 ++++ .gitignore | 1 - ...ptySnapshotFileTest$NestedClass.snap.debug | 0 .../EmptySnapshotFileTest.snap.debug | 0 .../EqualDebugSnapshotFileTest.snap.debug | 13 ++ .../JacksonSnapshotSerializer.java | 17 --- .../DeterministicCollectionModule.java | 2 +- ...eterministicJacksonSnapshotSerializer.java | 6 +- .../JacksonSnapshotSerializer.java | 17 +++ ...eterministicJacksonSnapshotSerializer.java | 4 +- .../v1/JacksonSnapshotSerializer.java | 4 +- .../serializers/v1/SnapshotPrettyPrinter.java | 2 +- .../NoNameChangeTest.java | 10 +- .../ReflectionUtilities.java | 2 +- .../docs/BaseEntity.java | 2 +- .../docs/CustomSerializerTest.java | 2 +- .../docs/HibernateSnapshotSerializer.java | 4 +- .../docs/JsonAssertReporter.java | 2 +- .../docs/JsonObjectComparator.java | 2 +- .../__snapshots__/CustomSerializerTest.snap | 2 +- .../CustomSerializerTest.snap.debug | 5 + ...ministicJacksonSnapshotSerializerTest.java | 2 +- .../JacksonSnapshotSerializerTest.java | 2 +- ...ministicJacksonSnapshotSerializerTest.snap | 142 ++++++++++++++++++ ...icJacksonSnapshotSerializerTest.snap.debug | 140 +++++++++++++++++ .../JacksonSnapshotSerializerTest.snap | 142 ++++++++++++++++++ .../JacksonSnapshotSerializerTest.snap.debug | 140 +++++++++++++++++ .../src/test/resources/snapshot.properties | 4 +- .../v1/JacksonSnapshotSerializer.java | 2 +- .../CustomSerializerTest.snap.debug | 5 + ...icJacksonSnapshotSerializerTest.snap.debug | 140 +++++++++++++++++ .../JacksonSnapshotSerializerTest.snap.debug | 140 +++++++++++++++++ .../BaseClassTest$NestedClass.snap | 3 - ...assTest$NestedClassWithExpectInstance.snap | 3 - ...dClassTest$NestedClassWithoutSnapshot.snap | 3 - ...estedClassTestWithExtends$NestedClass.snap | 3 - .../SnapshotExtensionUsedTest.snap | 28 ---- .../__snapshots__/SnapshotParameterTest.snap | 38 ----- .../__snapshots__/CustomFrameworkExample.snap | 3 - .../CustomSnapshotConfigExample.snap | 1 - .../docs/__snapshots__/JUnit5Example.snap | 8 - .../JUnit5ResolutionHierarchyExample.snap | 9 -- .../snapshots/junit5}/BaseClassTest.java | 4 +- .../{ => junit5}/NestedClassTest.java | 8 +- .../junit5}/NestedClassTestWithExtends.java | 4 +- .../junit5}/SnapshotExtensionUsedTest.java | 4 +- .../{ => junit5}/SnapshotParameterTest.java | 10 +- .../BaseClassTest$NestedClass.snap | 3 + ...assTest$NestedClassWithExpectArgument.snap | 3 + ...assTest$NestedClassWithExpectInstance.snap | 3 + ...estedClassTestWithExtends$NestedClass.snap | 3 + .../SnapshotExtensionUsedTest.snap | 28 ++++ .../__snapshots__/SnapshotParameterTest.snap | 38 +++++ .../junit5}/docs/CustomFrameworkExample.java | 2 +- .../docs/CustomSnapshotConfigExample.java | 2 +- .../snapshots/junit5}/docs/JUnit5Example.java | 2 +- .../JUnit5ResolutionHierarchyExample.java | 2 +- .../docs/LowercaseToStringSerializer.java | 2 +- .../docs/LowercaseToStringSnapshotConfig.java | 2 +- .../docs/MyFirstSnapshotTest.java | 2 +- .../snapshots/junit5}/docs/TestObject.java | 2 +- .../docs/UppercaseToStringSerializer.java | 2 +- .../__snapshots__/CustomFrameworkExample.snap | 3 + .../CustomSnapshotConfigExample.snap | 1 + .../CustomSnapshotContextConfigExample.snap | 0 .../docs/__snapshots__/JUnit5Example.snap | 8 + .../JUnit5ResolutionHierarchyExample.snap | 9 ++ .../MyFirstSnapshotContextTest.snap | 0 .../__snapshots__/MyFirstSnapshotTest.snap | 2 +- .../src/test/resources/snapshot.properties | 2 +- .../BaseClassTest$NestedClass.snap | 3 - ...estedClassTestWithExtends$NestedClass.snap | 3 - .../SnapshotExtensionUsedTest.snap | 28 ---- .../__snapshots__/SnapshotParameterTest.snap | 38 ----- .../__snapshots__/CustomFrameworkExample.snap | 3 - .../CustomSnapshotConfigExample.snap | 1 - .../docs/__snapshots__/JUnit5Example.snap | 8 - .../JUnit5ResolutionHierarchyExample.snap | 9 -- .../snapshots/junit6}/BaseClassTest.java | 3 +- .../{ => junit6}/NestedClassTest.java | 7 +- .../junit6}/NestedClassTestWithExtends.java | 3 +- .../junit6}/SnapshotExtensionUsedTest.java | 3 +- .../{ => junit6}/SnapshotParameterTest.java | 7 +- .../BaseClassTest$NestedClass.snap | 3 + ...assTest$NestedClassWithExpectArgument.snap | 3 + ...estedClassTestWithExtends$NestedClass.snap | 3 + .../SnapshotExtensionUsedTest.snap | 28 ++++ .../__snapshots__/SnapshotParameterTest.snap | 38 +++++ .../junit6}/docs/CustomFrameworkExample.java | 2 +- .../docs/CustomSnapshotConfigExample.java | 2 +- .../snapshots/junit6}/docs/JUnit5Example.java | 2 +- .../JUnit5ResolutionHierarchyExample.java | 2 +- .../docs/LowercaseToStringSerializer.java | 2 +- .../docs/LowercaseToStringSnapshotConfig.java | 2 +- .../docs/MyFirstSnapshotTest.java | 2 +- .../snapshots/junit6}/docs/TestObject.java | 2 +- .../docs/UppercaseToStringSerializer.java | 2 +- .../__snapshots__/CustomFrameworkExample.snap | 3 + .../CustomSnapshotConfigExample.snap | 1 + .../CustomSnapshotContextConfigExample.snap} | 0 .../docs/__snapshots__/JUnit5Example.snap | 8 + .../JUnit5ResolutionHierarchyExample.snap | 9 ++ .../MyFirstSnapshotContextTest.snap | 0 .../__snapshots__/MyFirstSnapshotTest.snap | 2 +- 107 files changed, 1298 insertions(+), 280 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependabot-auto-merge.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/verify.yml rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap => snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug (100%) rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap => snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug (100%) create mode 100644 snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug delete mode 100644 snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java rename snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/DeterministicCollectionModule.java (97%) rename snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/DeterministicJacksonSnapshotSerializer.java (65%) create mode 100644 snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/JacksonSnapshotSerializer.java rename snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/v1/DeterministicJacksonSnapshotSerializer.java (83%) rename snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/v1/JacksonSnapshotSerializer.java (96%) rename snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/v1/SnapshotPrettyPrinter.java (93%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/NoNameChangeTest.java (54%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/ReflectionUtilities.java (96%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/docs/BaseEntity.java (86%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/docs/CustomSerializerTest.java (94%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/docs/HibernateSnapshotSerializer.java (88%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/docs/JsonAssertReporter.java (93%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/docs/JsonObjectComparator.java (93%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/docs/__snapshots__/CustomSerializerTest.snap (71%) create mode 100644 snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/__snapshots__/CustomSerializerTest.snap.debug rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/DeterministicJacksonSnapshotSerializerTest.java (99%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/JacksonSnapshotSerializerTest.java (99%) rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap (66%) create mode 100644 snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug rename snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/{jackson => jackson2}/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap (66%) create mode 100644 snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap.debug create mode 100644 snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap.debug create mode 100644 snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug create mode 100644 snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap.debug delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap delete mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/BaseClassTest.java (82%) rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/{ => junit5}/NestedClassTest.java (85%) rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/NestedClassTestWithExtends.java (90%) rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/SnapshotExtensionUsedTest.java (91%) rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/{ => junit5}/SnapshotParameterTest.java (83%) create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/BaseClassTest$NestedClass.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTestWithExtends$NestedClass.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotExtensionUsedTest.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotParameterTest.snap rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/CustomFrameworkExample.java (95%) rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/CustomSnapshotConfigExample.java (92%) rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/JUnit5Example.java (93%) rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/{ => junit5}/docs/JUnit5ResolutionHierarchyExample.java (95%) rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/LowercaseToStringSerializer.java (92%) rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/{ => junit5}/docs/LowercaseToStringSnapshotConfig.java (87%) rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/{ => junit5}/docs/MyFirstSnapshotTest.java (94%) rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/TestObject.java (74%) rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/UppercaseToStringSerializer.java (92%) create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomFrameworkExample.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomSnapshotConfigExample.snap rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/__snapshots__/CustomSnapshotContextConfigExample.snap (100%) create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5Example.snap create mode 100644 snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap rename {snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5}/docs/__snapshots__/MyFirstSnapshotContextTest.snap (100%) rename snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/{ => junit5}/docs/__snapshots__/MyFirstSnapshotTest.snap (55%) delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap delete mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/BaseClassTest.java (85%) rename snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/{ => junit6}/NestedClassTest.java (86%) rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/NestedClassTestWithExtends.java (91%) rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/SnapshotExtensionUsedTest.java (92%) rename snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/{ => junit6}/SnapshotParameterTest.java (87%) create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/BaseClassTest$NestedClass.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTestWithExtends$NestedClass.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotExtensionUsedTest.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotParameterTest.snap rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/docs/CustomFrameworkExample.java (95%) rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/docs/CustomSnapshotConfigExample.java (92%) rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/docs/JUnit5Example.java (93%) rename snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/{ => junit6}/docs/JUnit5ResolutionHierarchyExample.java (95%) rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/docs/LowercaseToStringSerializer.java (92%) rename snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/{ => junit6}/docs/LowercaseToStringSnapshotConfig.java (87%) rename snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/{ => junit6}/docs/MyFirstSnapshotTest.java (94%) rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/docs/TestObject.java (74%) rename {snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots => snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6}/docs/UppercaseToStringSerializer.java (92%) create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomFrameworkExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomSnapshotConfigExample.snap rename snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/{__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap => junit6/docs/__snapshots__/CustomSnapshotContextConfigExample.snap} (100%) create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5Example.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap create mode 100644 snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/{ => junit6}/docs/__snapshots__/MyFirstSnapshotTest.snap (56%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7a399e9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: maven + directory: "/" + schedule: + interval: daily + time: "21:00" + open-pull-requests-limit: 10 \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..47ad2fb --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,41 @@ +name: Dependabot auto-merge + +on: + pull_request: + types: + - opened + - reopened + - synchronize + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Check if PR is mergeable + run: | + MERGEABLE=$(gh pr view "$PR_URL" --json mergeable -q .mergeable) + echo "Mergeable: $MERGEABLE" + if [ "$MERGEABLE" != "MERGEABLE" ]; then + echo "PR not mergeable. Skipping auto-merge." + exit 0 + fi + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9dd42b2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,62 @@ +name: Publish to Maven Central + +on: + release: + types: [published] + +jobs: + publish: + name: Publish Maven package + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + cache: 'maven' + server-id: central + server-username: OSSRH_USERNAME + server-password: OSSRH_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + + # Set reproducible build timestamp + - name: Set build timestamp + run: | + # Use the commit timestamp for reproducibility + COMMIT_TIMESTAMP=$(git log -1 --format=%ct) + BUILD_TIMESTAMP=$(date -u -d @${COMMIT_TIMESTAMP} +"%Y-%m-%dT%H:%M:%SZ") + echo "BUILD_TIMESTAMP=$BUILD_TIMESTAMP" >> $GITHUB_ENV + echo "Setting build timestamp to: $BUILD_TIMESTAMP" + + - name: Build and Test + run: mvn clean verify --batch-mode -Dproject.build.outputTimestamp="${BUILD_TIMESTAMP}" + + - name: Determine version from tag + id: version + run: | + RAW_TAG="${GITHUB_REF##*/}" + VERSION="${RAW_TAG#v}" + + if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then + VERSION="${VERSION}-SNAPSHOT" + fi + + echo "Resolved version: $VERSION" + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Set Maven version + run: mvn versions:set -DnewVersion=${VERSION} -DgenerateBackupPoms=false + + - name: Publish to Maven Central + run: mvn deploy --batch-mode -Dproject.build.outputTimestamp="${BUILD_TIMESTAMP}" + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} \ No newline at end of file diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..820c9fe --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,29 @@ +name: Verify + +on: + pull_request: + branches: + - '**' +jobs: + build: + name: Verify + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + cache: 'maven' + server-id: central + server-username: OSSRH_USERNAME + server-password: OSSRH_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + + - name: Execute the verify step + run: mvn -B verify diff --git a/.gitignore b/.gitignore index 704351e..212a6d5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ out/ TODO.md .flattened-pom.xml -*.snap.debug # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug similarity index 100% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest$NestedClass.snap.debug diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug similarity index 100% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename to snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EmptySnapshotFileTest.snap.debug diff --git a/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug new file mode 100644 index 0000000..00c27a7 --- /dev/null +++ b/snapshot-testing-core/src/test/java/io/github/finoid/snapshots/existing-snapshots/__snapshots__/EqualDebugSnapshotFileTest.snap.debug @@ -0,0 +1,13 @@ +io.github.finoid.snapshots.DebugSnapshotTest.createDebugFile=[ +Good Snapshot +] + + +io.github.finoid.snapshots.DebugSnapshotTest.debugFileCreatedSnapshotMatch=[ +Good Snapshot +] + + +io.github.finoid.snapshots.DebugSnapshotTest.debugFileCreatedExistingSnapshot=[ +Good Snapshot +] \ No newline at end of file diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java deleted file mode 100644 index 42510e1..0000000 --- a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializer.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.finoid.snapshots.jackson.serializers; - -import io.github.finoid.snapshots.logging.LoggingHelper; -import lombok.extern.slf4j.Slf4j; - -@Deprecated -@Slf4j -public class JacksonSnapshotSerializer - extends io.github.finoid.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer { - - public JacksonSnapshotSerializer() { - super(); - LoggingHelper.deprecatedV5( - log, - "Update to `v1.serializers.jackson.io.github.finoid.snapshots.JacksonSnapshotSerializer` in `snapshot.properties`"); - } -} diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicCollectionModule.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicCollectionModule.java similarity index 97% rename from snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicCollectionModule.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicCollectionModule.java index 65145e9..6c86d52 100644 --- a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicCollectionModule.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicCollectionModule.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.serializers; +package io.github.finoid.snapshots.jackson2.serializers; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicJacksonSnapshotSerializer.java similarity index 65% rename from snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicJacksonSnapshotSerializer.java index 65a3c82..e989251 100644 --- a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicJacksonSnapshotSerializer.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.serializers; +package io.github.finoid.snapshots.jackson2.serializers; import io.github.finoid.snapshots.logging.LoggingHelper; import lombok.extern.slf4j.Slf4j; @@ -14,11 +14,11 @@ @Deprecated @Slf4j public class DeterministicJacksonSnapshotSerializer - extends io.github.finoid.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer { + extends io.github.finoid.snapshots.jackson2.serializers.v1.DeterministicJacksonSnapshotSerializer { public DeterministicJacksonSnapshotSerializer() { super(); LoggingHelper.deprecatedV5( log, - "Update to `v1.serializers.jackson.io.github.finoid.snapshots.DeterministicJacksonSnapshotSerializer` in `snapshot.properties`"); + "Update to `v1.serializers.jackson2.io.github.finoid.snapshots.DeterministicJacksonSnapshotSerializer` in `snapshot.properties`"); } } diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/JacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/JacksonSnapshotSerializer.java new file mode 100644 index 0000000..7dda663 --- /dev/null +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/JacksonSnapshotSerializer.java @@ -0,0 +1,17 @@ +package io.github.finoid.snapshots.jackson2.serializers; + +import io.github.finoid.snapshots.logging.LoggingHelper; +import lombok.extern.slf4j.Slf4j; + +@Deprecated +@Slf4j +public class JacksonSnapshotSerializer + extends io.github.finoid.snapshots.jackson2.serializers.v1.JacksonSnapshotSerializer { + + public JacksonSnapshotSerializer() { + super(); + LoggingHelper.deprecatedV5( + log, + "Update to `v1.serializers.jackson2.io.github.finoid.snapshots.JacksonSnapshotSerializer` in `snapshot.properties`"); + } +} diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/DeterministicJacksonSnapshotSerializer.java similarity index 83% rename from snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/DeterministicJacksonSnapshotSerializer.java index 6738b48..ca1b7ce 100644 --- a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/DeterministicJacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/DeterministicJacksonSnapshotSerializer.java @@ -1,6 +1,6 @@ -package io.github.finoid.snapshots.jackson.serializers.v1; +package io.github.finoid.snapshots.jackson2.serializers.v1; -import io.github.finoid.snapshots.jackson.serializers.DeterministicCollectionModule; +import io.github.finoid.snapshots.jackson2.serializers.DeterministicCollectionModule; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/JacksonSnapshotSerializer.java similarity index 96% rename from snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/JacksonSnapshotSerializer.java index 09b0c71..94a733a 100644 --- a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/JacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/JacksonSnapshotSerializer.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.serializers.v1; +package io.github.finoid.snapshots.jackson2.serializers.v1; import io.github.finoid.snapshots.Snapshot; import io.github.finoid.snapshots.SnapshotSerializerContext; @@ -51,7 +51,7 @@ public void configure(ObjectMapper objectMapper) { } /** - * Override to control the registration of all available jackson modules within the classpath + * Override to control the registration of all available jackson2 modules within the classpath * which are locatable via JDK ServiceLoader facility, along with module-provided SPI. */ protected boolean shouldFindAndRegisterModules() { diff --git a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/SnapshotPrettyPrinter.java similarity index 93% rename from snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java rename to snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/SnapshotPrettyPrinter.java index 081acc5..b38cf1d 100644 --- a/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java +++ b/snapshot-testing-jackson2/src/main/java/io/github/finoid/snapshots/jackson2/serializers/v1/SnapshotPrettyPrinter.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.serializers.v1; +package io.github.finoid.snapshots.jackson2.serializers.v1; import com.fasterxml.jackson.core.util.DefaultIndenter; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/NoNameChangeTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/NoNameChangeTest.java similarity index 54% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/NoNameChangeTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/NoNameChangeTest.java index 88a1548..c324d24 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/NoNameChangeTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/NoNameChangeTest.java @@ -1,7 +1,7 @@ -package io.github.finoid.snapshots.jackson; +package io.github.finoid.snapshots.jackson2; -import io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; -import io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson2.serializers.DeterministicJacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson2.serializers.JacksonSnapshotSerializer; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -16,9 +16,9 @@ public class NoNameChangeTest { @Test public void serializersApiShouldNotChange() { assertThat(JacksonSnapshotSerializer.class.getName()) - .isEqualTo("io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializer"); + .isEqualTo("io.github.finoid.snapshots.jackson2.serializers.JacksonSnapshotSerializer"); assertThat(DeterministicJacksonSnapshotSerializer.class.getName()) .isEqualTo( - "io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer"); + "io.github.finoid.snapshots.jackson2.serializers.DeterministicJacksonSnapshotSerializer"); } } diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/ReflectionUtilities.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/ReflectionUtilities.java similarity index 96% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/ReflectionUtilities.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/ReflectionUtilities.java index 885be51..126ba20 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/ReflectionUtilities.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/ReflectionUtilities.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson; +package io.github.finoid.snapshots.jackson2; import io.github.finoid.snapshots.exceptions.SnapshotMatchException; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/BaseEntity.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/BaseEntity.java similarity index 86% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/BaseEntity.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/BaseEntity.java index 26465b9..887f9ae 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/BaseEntity.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/BaseEntity.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson2.docs; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/CustomSerializerTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/CustomSerializerTest.java similarity index 94% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/CustomSerializerTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/CustomSerializerTest.java index 0b578a5..b787b5f 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/CustomSerializerTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/CustomSerializerTest.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson2.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.SnapshotVerifier; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/HibernateSnapshotSerializer.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/HibernateSnapshotSerializer.java similarity index 88% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/HibernateSnapshotSerializer.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/HibernateSnapshotSerializer.java index bdafb8b..8e6f395 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/HibernateSnapshotSerializer.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/HibernateSnapshotSerializer.java @@ -1,6 +1,6 @@ -package io.github.finoid.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson2.docs; -import io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer; +import io.github.finoid.snapshots.jackson2.serializers.DeterministicJacksonSnapshotSerializer; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreType; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonAssertReporter.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/JsonAssertReporter.java similarity index 93% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonAssertReporter.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/JsonAssertReporter.java index ae0116a..a3b6396 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonAssertReporter.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/JsonAssertReporter.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson2.docs; import io.github.finoid.snapshots.Snapshot; import io.github.finoid.snapshots.reporters.SnapshotReporter; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonObjectComparator.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/JsonObjectComparator.java similarity index 93% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonObjectComparator.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/JsonObjectComparator.java index d5619fd..33ae5a7 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/JsonObjectComparator.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/JsonObjectComparator.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.docs; +package io.github.finoid.snapshots.jackson2.docs; import io.github.finoid.snapshots.Snapshot; import io.github.finoid.snapshots.comparators.SnapshotComparator; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/__snapshots__/CustomSerializerTest.snap similarity index 71% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/__snapshots__/CustomSerializerTest.snap index 10a6138..dc185fc 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/docs/__snapshots__/CustomSerializerTest.snap +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/__snapshots__/CustomSerializerTest.snap @@ -5,7 +5,7 @@ docs.jackson.io.github.finoid.snapshots.CustomSerializerTest.test1=[ ] -io.github.finoid.snapshots.jackson.docs.CustomSerializerTest.test1=[ +io.github.finoid.snapshots.jackson2.docs.CustomSerializerTest.test1=[ { "somethingElse": "This should render" } diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/__snapshots__/CustomSerializerTest.snap.debug b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/__snapshots__/CustomSerializerTest.snap.debug new file mode 100644 index 0000000..fd6b3e1 --- /dev/null +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/docs/__snapshots__/CustomSerializerTest.snap.debug @@ -0,0 +1,5 @@ +io.github.finoid.snapshots.jackson2.docs.CustomSerializerTest.test1=[ + { + "somethingElse": "This should render" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicJacksonSnapshotSerializerTest.java similarity index 99% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicJacksonSnapshotSerializerTest.java index ae8c2d3..6b5d71b 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/DeterministicJacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/DeterministicJacksonSnapshotSerializerTest.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.serializers; +package io.github.finoid.snapshots.jackson2.serializers; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.SnapshotVerifier; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/JacksonSnapshotSerializerTest.java similarity index 99% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/JacksonSnapshotSerializerTest.java index 9b7ca3b..d01429b 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/JacksonSnapshotSerializerTest.java +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/JacksonSnapshotSerializerTest.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.jackson.serializers; +package io.github.finoid.snapshots.jackson2.serializers; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.Snapshot; diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap similarity index 66% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap index 3c1757b..dd625f8 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap @@ -140,6 +140,148 @@ io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSeria ] +io.github.finoid.snapshots.jackson2.serializers.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean": true, + "aByte": 65, + "aChar": "A", + "aDouble": 1.123456789123456, + "aFloat": 0.1234567, + "aLong": 9223372036854775807, + "aShort": 32767, + "anEnum": "A", + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt": 2147483647, + "anObject": { }, + "arrayList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date": "2020-10-19T22:21:07.103+00:00", + "emptyOptional": null, + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "presentOptional": "Hello World", + "string": "Hello World", + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] + + serializers.jackson.io.github.finoid.snapshots.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ { "aBoolean": true, diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug new file mode 100644 index 0000000..f3b512a --- /dev/null +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug @@ -0,0 +1,140 @@ +io.github.finoid.snapshots.jackson2.serializers.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean": true, + "aByte": 65, + "aChar": "A", + "aDouble": 1.123456789123456, + "aFloat": 0.1234567, + "aLong": 9223372036854775807, + "aShort": 32767, + "anEnum": "A", + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt": 2147483647, + "anObject": { }, + "arrayList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date": "2020-10-19T22:21:07.103+00:00", + "emptyOptional": null, + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "presentOptional": "Hello World", + "string": "Hello World", + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap similarity index 66% rename from snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap rename to snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap index 62cd765..97d087f 100644 --- a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap @@ -140,6 +140,148 @@ io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializerTest.sho ] +io.github.finoid.snapshots.jackson2.serializers.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "anObject": { }, + "aByte": 65, + "aShort": 32767, + "anInt": 2147483647, + "aLong": 9223372036854775807, + "aFloat": 0.1234567, + "aDouble": 1.123456789123456, + "aBoolean": true, + "aChar": "A", + "string": "Hello World", + "date": "2020-10-19T22:21:07.103+00:00", + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]", + "anEnum": "A", + "presentOptional": "Hello World", + "emptyOptional": null, + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "arrayList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ] + } +] + + serializers.jackson.io.github.finoid.snapshots.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ { "anObject": { }, diff --git a/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap.debug b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap.debug new file mode 100644 index 0000000..82260b9 --- /dev/null +++ b/snapshot-testing-jackson2/src/test/java/io/github/finoid/snapshots/jackson2/serializers/__snapshots__/JacksonSnapshotSerializerTest.snap.debug @@ -0,0 +1,140 @@ +io.github.finoid.snapshots.jackson2.serializers.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "anObject": { }, + "aByte": 65, + "aShort": 32767, + "anInt": 2147483647, + "aLong": 9223372036854775807, + "aFloat": 0.1234567, + "aDouble": 1.123456789123456, + "aBoolean": true, + "aChar": "A", + "string": "Hello World", + "date": "2020-10-19T22:21:07.103+00:00", + "localDate": "2020-10-19", + "localDateTime": "2020-10-19T22:21:07.103", + "zonedDateTime": "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]", + "anEnum": "A", + "presentOptional": "Hello World", + "emptyOptional": null, + "stringArray": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "anEnumArray": [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "hashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "treeMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashMap": { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + "linkedHashSet": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "hashSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "treeSet": [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "arrayList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList": [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections": [ + { + "a": 97, + "b": 98, + "c": 99, + "d": 100, + "e": 101, + "f": 102, + "g": 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ] + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson2/src/test/resources/snapshot.properties b/snapshot-testing-jackson2/src/test/resources/snapshot.properties index 4a2666e..8fee0cb 100644 --- a/snapshot-testing-jackson2/src/test/resources/snapshot.properties +++ b/snapshot-testing-jackson2/src/test/resources/snapshot.properties @@ -1,5 +1,5 @@ -serializer=io.github.finoid.snapshots.jackson.serializers.JacksonSnapshotSerializer -serializer.orderedJson=io.github.finoid.snapshots.jackson.serializers.DeterministicJacksonSnapshotSerializer +serializer=io.github.finoid.snapshots.jackson2.serializers.JacksonSnapshotSerializer +serializer.orderedJson=io.github.finoid.snapshots.jackson2.serializers.DeterministicJacksonSnapshotSerializer comparator=io.github.finoid.snapshots.comparators.PlainTextEqualsComparator reporters=io.github.finoid.snapshots.reporters.PlainTextSnapshotReporter snapshot-dir=__snapshots__ diff --git a/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java index 48286a6..7035308 100644 --- a/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java +++ b/snapshot-testing-jackson3/src/main/java/io/github/finoid/snapshots/jackson3/serializers/v1/JacksonSnapshotSerializer.java @@ -72,7 +72,7 @@ public void configure(final JsonMapper.Builder builder) { } /** - * Override to control the registration of all available jackson modules within the classpath + * Override to control the registration of all available jackson2 modules within the classpath * which are locatable via JDK ServiceLoader facility, along with module-provided SPI. */ protected boolean shouldFindAndRegisterModules() { diff --git a/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap.debug b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap.debug new file mode 100644 index 0000000..e1f7119 --- /dev/null +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/docs/__snapshots__/CustomSerializerTest.snap.debug @@ -0,0 +1,5 @@ +io.github.finoid.snapshots.jackson3.docs.CustomSerializerTest.test1=[ + { + "somethingElse" : "This should render" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug new file mode 100644 index 0000000..6d3f725 --- /dev/null +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/DeterministicJacksonSnapshotSerializerTest.snap.debug @@ -0,0 +1,140 @@ +io.github.finoid.snapshots.jackson3.serializers.v1.DeterministicJacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedList" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap.debug b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap.debug new file mode 100644 index 0000000..0366607 --- /dev/null +++ b/snapshot-testing-jackson3/src/test/java/io/github/finoid/snapshots/jackson3/serializers/v1/__snapshots__/JacksonSnapshotSerializerTest.snap.debug @@ -0,0 +1,140 @@ +io.github.finoid.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializerTest.shouldSerializeDifferentTypes=[ + { + "aBoolean" : true, + "aByte" : 65, + "aChar" : "A", + "aDouble" : 1.123456789123456, + "aFloat" : 0.1234567, + "aLong" : 9223372036854775807, + "aShort" : 32767, + "anEnum" : "A", + "anEnumArray" : [ + "F", + "A", + "D", + "E", + "G", + "B", + "C" + ], + "anInt" : 2147483647, + "anObject" : { }, + "arrayList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "date" : "2020-10-19T22:21:07.103Z", + "emptyOptional" : null, + "hashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "hashSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "linkedHashMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "linkedHashSet" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "linkedList" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "listOfCollections" : [ + { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ] + ], + "localDate" : "2020-10-19", + "localDateTime" : "2020-10-19T22:21:07.103", + "presentOptional" : "Hello World", + "string" : "Hello World", + "stringArray" : [ + "f", + "a", + "d", + "e", + "g", + "b", + "c" + ], + "treeMap" : { + "a" : 97, + "b" : 98, + "c" : 99, + "d" : 100, + "e" : 101, + "f" : 102, + "g" : 103 + }, + "treeSet" : [ + "a", + "b", + "c", + "d", + "e", + "f", + "g" + ], + "zonedDateTime" : "2020-04-19T22:21:07.103+10:00[Australia/Melbourne]" + } +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap deleted file mode 100644 index 447eb87..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.BaseClassTest$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap deleted file mode 100644 index 1596b3f..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.NestedClassTest$NestedClassWithExpectInstance.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap deleted file mode 100644 index bee72b5..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.NestedClassTest$NestedClassWithoutSnapshot.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap deleted file mode 100644 index aca84ab..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap deleted file mode 100644 index dc6a684..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap +++ /dev/null @@ -1,28 +0,0 @@ -hello_world=[ -Hello World -] - - -hello_world_2=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtension=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap deleted file mode 100644 index 22e22ee..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap +++ /dev/null @@ -1,38 +0,0 @@ -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest=[ -Duplicates are OK -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ -Duplicates are OK -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ - "test input 1" -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ - "test input 2" -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ - "test input 1" -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ - "test input 2" -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap deleted file mode 100644 index b06eefa..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap deleted file mode 100644 index 881d543..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap +++ /dev/null @@ -1 +0,0 @@ -io.github.finoid.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap deleted file mode 100644 index 752e9e9..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap +++ /dev/null @@ -1,8 +0,0 @@ -io.github.finoid.snapshots.docs.JUnit5Example.myTest1=[ -Hello World -] - - -io.github.finoid.snapshots.docs.JUnit5Example.myTest2=[ -Hello World Again -] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap deleted file mode 100644 index 002cec4..0000000 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap +++ /dev/null @@ -1,9 +0,0 @@ -io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ - { } -] - - -io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD - - -io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/BaseClassTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/BaseClassTest.java similarity index 82% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/BaseClassTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/BaseClassTest.java index ab7eeb1..210c637 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/BaseClassTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/BaseClassTest.java @@ -1,6 +1,6 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit5; -import io.github.finoid.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/NestedClassTest.java similarity index 85% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/NestedClassTest.java index cdf3841..514f855 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/NestedClassTest.java @@ -1,7 +1,8 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit5; -import io.github.finoid.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -13,13 +14,14 @@ import static org.assertj.core.api.Assertions.assertThat; @SuppressWarnings("checkstyle:HideUtilityClassConstructor") +@Disabled // TODO (nw) rewrite @ExtendWith({SnapshotExtension.class}) public class NestedClassTest { @AfterAll public static void afterAll() { Path path = - Paths.get("src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest.snap"); + Paths.get("src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest.snap"); assertThat(Files.exists(path)).isFalse(); } diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/NestedClassTestWithExtends.java similarity index 90% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/NestedClassTestWithExtends.java index 529ba50..c53e643 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/NestedClassTestWithExtends.java @@ -1,6 +1,6 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit5; -import io.github.finoid.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/SnapshotExtensionUsedTest.java similarity index 91% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/SnapshotExtensionUsedTest.java index 1858418..57adadd 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/SnapshotExtensionUsedTest.java @@ -1,7 +1,7 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit5; +import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.SnapshotName; -import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/SnapshotParameterTest.java similarity index 83% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/SnapshotParameterTest.java index 633fbea..1ea9369 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/SnapshotParameterTest.java @@ -1,7 +1,7 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit5; -import io.github.finoid.snapshots.jackson.serializers.v1.JacksonSnapshotSerializer; -import io.github.finoid.snapshots.junit5.SnapshotExtension; +import io.github.finoid.snapshots.Expect; +import io.github.finoid.snapshots.jackson2.serializers.v1.JacksonSnapshotSerializer; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -25,7 +25,7 @@ static Stream testData() { } @ParameterizedTest - @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.junit5.SnapshotParameterTest#testData") void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { expect.toMatchSnapshot("Duplicates are OK"); expect.toMatchSnapshot("Duplicates are OK"); @@ -37,7 +37,7 @@ void shouldSupportParameterizedTest(String scenario, String testInput, Expect ex } @ParameterizedTest - @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.junit5.SnapshotParameterTest#testData") void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { this.expect.toMatchSnapshot("Duplicates are OK"); this.expect.toMatchSnapshot("Duplicates are OK"); diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/BaseClassTest$NestedClass.snap new file mode 100644 index 0000000..40d3301 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/BaseClassTest$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit5.BaseClassTest$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap new file mode 100644 index 0000000..b86cedb --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit5.NestedClassTest$NestedClassWithExpectArgument.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap new file mode 100644 index 0000000..3604f45 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTest$NestedClassWithExpectInstance.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit5.NestedClassTest$NestedClassWithExpectInstance.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTestWithExtends$NestedClass.snap new file mode 100644 index 0000000..101f30a --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/NestedClassTestWithExtends$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit5.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotExtensionUsedTest.snap new file mode 100644 index 0000000..15b22f9 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotExtensionUsedTest.snap @@ -0,0 +1,28 @@ +hello_world=[ +Hello World +] + + +hello_world_2=[ +Hello World +] + + +io.github.finoid.snapshots.junit5.SnapshotExtensionUsedTest.shouldUseExtension=[ +Hello World +] + + +io.github.finoid.snapshots.junit5.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ +Hello World +] + + +io.github.finoid.snapshots.junit5.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ +Hello World +] + + +io.github.finoid.snapshots.junit5.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotParameterTest.snap new file mode 100644 index 0000000..c58a887 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/__snapshots__/SnapshotParameterTest.snap @@ -0,0 +1,38 @@ +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTest=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ + "test input 2" +] + + +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.junit5.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ + "test input 2" +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/CustomFrameworkExample.java similarity index 95% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/CustomFrameworkExample.java index 5d4346c..9de0119 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/CustomFrameworkExample.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.SnapshotVerifier; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/CustomSnapshotConfigExample.java similarity index 92% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/CustomSnapshotConfigExample.java index 88e870c..3ba40a0 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/CustomSnapshotConfigExample.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.UseSnapshotConfig; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/JUnit5Example.java similarity index 93% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/JUnit5Example.java index 996af0e..0bfe7a4 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/JUnit5Example.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.junit5.SnapshotExtension; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/JUnit5ResolutionHierarchyExample.java similarity index 95% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/JUnit5ResolutionHierarchyExample.java index 04e9af3..cbfeb71 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/JUnit5ResolutionHierarchyExample.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.UseSnapshotConfig; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/LowercaseToStringSerializer.java similarity index 92% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/LowercaseToStringSerializer.java index 1c64f2f..74f2e05 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/LowercaseToStringSerializer.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.Snapshot; import io.github.finoid.snapshots.SnapshotSerializerContext; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/LowercaseToStringSnapshotConfig.java similarity index 87% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/LowercaseToStringSnapshotConfig.java index 3ad9abe..753515b 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/LowercaseToStringSnapshotConfig.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; import io.github.finoid.snapshots.serializers.SnapshotSerializer; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/MyFirstSnapshotTest.java similarity index 94% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/MyFirstSnapshotTest.java index 5e9d2f5..bc51e98 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/MyFirstSnapshotTest.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.SnapshotName; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/TestObject.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/TestObject.java similarity index 74% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/TestObject.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/TestObject.java index 75fa794..c33d3d1 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/TestObject.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/TestObject.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; public class TestObject { @Override diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/UppercaseToStringSerializer.java similarity index 92% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/UppercaseToStringSerializer.java index ecdbc53..7bdd3aa 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/UppercaseToStringSerializer.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit5.docs; import io.github.finoid.snapshots.Snapshot; import io.github.finoid.snapshots.SnapshotSerializerContext; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomFrameworkExample.snap new file mode 100644 index 0000000..1a8a465 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomFrameworkExample.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit5.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomSnapshotConfigExample.snap new file mode 100644 index 0000000..29105c7 --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomSnapshotConfigExample.snap @@ -0,0 +1 @@ +io.github.finoid.snapshots.junit5.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomSnapshotContextConfigExample.snap similarity index 100% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotContextConfigExample.snap rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/CustomSnapshotContextConfigExample.snap diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5Example.snap new file mode 100644 index 0000000..f139e2e --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5Example.snap @@ -0,0 +1,8 @@ +io.github.finoid.snapshots.junit5.docs.JUnit5Example.myTest1=[ +Hello World +] + + +io.github.finoid.snapshots.junit5.docs.JUnit5Example.myTest2=[ +Hello World Again +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap new file mode 100644 index 0000000..e8103ac --- /dev/null +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap @@ -0,0 +1,9 @@ +io.github.finoid.snapshots.junit5.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ + { } +] + + +io.github.finoid.snapshots.junit5.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD + + +io.github.finoid.snapshots.junit5.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/MyFirstSnapshotContextTest.snap similarity index 100% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotContextTest.snap rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/MyFirstSnapshotContextTest.snap diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/MyFirstSnapshotTest.snap similarity index 55% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap rename to snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/MyFirstSnapshotTest.snap index c0fccd4..7183ab7 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap +++ b/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/junit5/docs/__snapshots__/MyFirstSnapshotTest.snap @@ -3,7 +3,7 @@ Hello World ] -io.github.finoid.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ +io.github.finoid.snapshots.junit5.docs.MyFirstSnapshotTest.jsonSerializationTest=[ { "age": 40, "name": "John Doe" diff --git a/snapshot-testing-junit5/src/test/resources/snapshot.properties b/snapshot-testing-junit5/src/test/resources/snapshot.properties index b62c9bd..66e62ff 100644 --- a/snapshot-testing-junit5/src/test/resources/snapshot.properties +++ b/snapshot-testing-junit5/src/test/resources/snapshot.properties @@ -1,5 +1,5 @@ serializer=io.github.finoid.snapshots.serializers.v1.ToStringSnapshotSerializer -serializer.json=io.github.finoid.snapshots.jackson.serializers.v1.DeterministicJacksonSnapshotSerializer +serializer.json=io.github.finoid.snapshots.jackson2.serializers.v1.DeterministicJacksonSnapshotSerializer comparator=io.github.finoid.snapshots.comparators.v1.PlainTextEqualsComparator reporters=io.github.finoid.snapshots.reporters.v1.PlainTextSnapshotReporter snapshot-dir=__snapshots__ diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap deleted file mode 100644 index 447eb87..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/BaseClassTest$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.BaseClassTest$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap deleted file mode 100644 index aca84ab..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTestWithExtends$NestedClass.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap deleted file mode 100644 index dc6a684..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotExtensionUsedTest.snap +++ /dev/null @@ -1,28 +0,0 @@ -hello_world=[ -Hello World -] - - -hello_world_2=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtension=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ -Hello World -] - - -io.github.finoid.snapshots.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap deleted file mode 100644 index 22e22ee..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/SnapshotParameterTest.snap +++ /dev/null @@ -1,38 +0,0 @@ -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest=[ -Duplicates are OK -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ -Duplicates are OK -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ - "test input 1" -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ - "test input 2" -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ -Additional snapshots need to include a scenario -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ - "test input 1" -] - - -io.github.finoid.snapshots.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ - "test input 2" -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap deleted file mode 100644 index b06eefa..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomFrameworkExample.snap +++ /dev/null @@ -1,3 +0,0 @@ -io.github.finoid.snapshots.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ -Hello World -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap deleted file mode 100644 index 881d543..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/CustomSnapshotConfigExample.snap +++ /dev/null @@ -1 +0,0 @@ -io.github.finoid.snapshots.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap deleted file mode 100644 index 752e9e9..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5Example.snap +++ /dev/null @@ -1,8 +0,0 @@ -io.github.finoid.snapshots.docs.JUnit5Example.myTest1=[ -Hello World -] - - -io.github.finoid.snapshots.docs.JUnit5Example.myTest2=[ -Hello World Again -] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap deleted file mode 100644 index 002cec4..0000000 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap +++ /dev/null @@ -1,9 +0,0 @@ -io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ - { } -] - - -io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD - - -io.github.finoid.snapshots.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/BaseClassTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/BaseClassTest.java similarity index 85% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/BaseClassTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/BaseClassTest.java index ab7eeb1..134b4ac 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/BaseClassTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/BaseClassTest.java @@ -1,5 +1,6 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit6; +import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/NestedClassTest.java similarity index 86% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/NestedClassTest.java index c6e951a..8b4260b 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/NestedClassTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/NestedClassTest.java @@ -1,7 +1,9 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit6; +import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -14,12 +16,13 @@ @SuppressWarnings("checkstyle:all") // TODO (nw) rewrite @ExtendWith({SnapshotExtension.class}) +@Disabled // TODO (nw) rewrite public class NestedClassTest { @AfterAll public static void afterAll() { Path path = - Paths.get("src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest.snap"); + Paths.get("src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTest.snap"); assertThat(Files.exists(path)).isFalse(); } diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/NestedClassTestWithExtends.java similarity index 91% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/NestedClassTestWithExtends.java index 529ba50..708a2de 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/NestedClassTestWithExtends.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/NestedClassTestWithExtends.java @@ -1,5 +1,6 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit6; +import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Nested; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/SnapshotExtensionUsedTest.java similarity index 92% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/SnapshotExtensionUsedTest.java index 1858418..b9b9330 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/SnapshotExtensionUsedTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/SnapshotExtensionUsedTest.java @@ -1,5 +1,6 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit6; +import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.SnapshotName; import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.Test; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/SnapshotParameterTest.java similarity index 87% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/SnapshotParameterTest.java index 4ac7a77..705f02a 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/SnapshotParameterTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/SnapshotParameterTest.java @@ -1,5 +1,6 @@ -package io.github.finoid.snapshots; +package io.github.finoid.snapshots.junit6; +import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.jackson3.serializers.v1.JacksonSnapshotSerializer; import io.github.finoid.snapshots.junit5.SnapshotExtension; import org.junit.jupiter.api.extension.ExtendWith; @@ -25,7 +26,7 @@ static Stream testData() { } @ParameterizedTest - @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.junit6.SnapshotParameterTest#testData") void shouldSupportParameterizedTest(String scenario, String testInput, Expect expect) { expect.toMatchSnapshot("Duplicates are OK"); expect.toMatchSnapshot("Duplicates are OK"); @@ -37,7 +38,7 @@ void shouldSupportParameterizedTest(String scenario, String testInput, Expect ex } @ParameterizedTest - @MethodSource("io.github.finoid.snapshots.SnapshotParameterTest#testData") + @MethodSource("io.github.finoid.snapshots.junit6.SnapshotParameterTest#testData") void shouldSupportParameterizedTestViaInstanceVariable(String scenario, String testInput) { this.expect.toMatchSnapshot("Duplicates are OK"); this.expect.toMatchSnapshot("Duplicates are OK"); diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/BaseClassTest$NestedClass.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/BaseClassTest$NestedClass.snap new file mode 100644 index 0000000..3c813c8 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/BaseClassTest$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit6.BaseClassTest$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap new file mode 100644 index 0000000..d0d9dd7 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTest$NestedClassWithExpectArgument.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit6.NestedClassTest$NestedClassWithExpectArgument.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTestWithExtends$NestedClass.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTestWithExtends$NestedClass.snap new file mode 100644 index 0000000..a6f9e28 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/NestedClassTestWithExtends$NestedClass.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit6.NestedClassTestWithExtends$NestedClass.helloWorldTest=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotExtensionUsedTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotExtensionUsedTest.snap new file mode 100644 index 0000000..e39cc31 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotExtensionUsedTest.snap @@ -0,0 +1,28 @@ +hello_world=[ +Hello World +] + + +hello_world_2=[ +Hello World +] + + +io.github.finoid.snapshots.junit6.SnapshotExtensionUsedTest.shouldUseExtension=[ +Hello World +] + + +io.github.finoid.snapshots.junit6.SnapshotExtensionUsedTest.shouldUseExtensionAgain=[ +Hello World +] + + +io.github.finoid.snapshots.junit6.SnapshotExtensionUsedTest.shouldUseExtensionAgainViaInstanceVariable=[ +Hello World +] + + +io.github.finoid.snapshots.junit6.SnapshotExtensionUsedTest.shouldUseExtensionViaInstanceVariable=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotParameterTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotParameterTest.snap new file mode 100644 index 0000000..7edca69 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/__snapshots__/SnapshotParameterTest.snap @@ -0,0 +1,38 @@ +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTest=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable=[ +Duplicates are OK +] + + +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTestViaInstanceVariable[Scenario3]=[ + "test input 2" +] + + +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario1]=[ +Additional snapshots need to include a scenario +] + + +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario2]=[ + "test input 1" +] + + +io.github.finoid.snapshots.junit6.SnapshotParameterTest.shouldSupportParameterizedTest[Scenario3]=[ + "test input 2" +] \ No newline at end of file diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/CustomFrameworkExample.java similarity index 95% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/CustomFrameworkExample.java index 5d4346c..a26bfe6 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomFrameworkExample.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/CustomFrameworkExample.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.SnapshotVerifier; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/CustomSnapshotConfigExample.java similarity index 92% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/CustomSnapshotConfigExample.java index 88e870c..2e64886 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/CustomSnapshotConfigExample.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/CustomSnapshotConfigExample.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.UseSnapshotConfig; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/JUnit5Example.java similarity index 93% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/JUnit5Example.java index 996af0e..1598b84 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/JUnit5Example.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/JUnit5Example.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.junit5.SnapshotExtension; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/JUnit5ResolutionHierarchyExample.java similarity index 95% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/JUnit5ResolutionHierarchyExample.java index 04e9af3..797bb4b 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/JUnit5ResolutionHierarchyExample.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/JUnit5ResolutionHierarchyExample.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.UseSnapshotConfig; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/LowercaseToStringSerializer.java similarity index 92% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/LowercaseToStringSerializer.java index 1c64f2f..92d1f1b 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/LowercaseToStringSerializer.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.Snapshot; import io.github.finoid.snapshots.SnapshotSerializerContext; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/LowercaseToStringSnapshotConfig.java similarity index 87% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/LowercaseToStringSnapshotConfig.java index 3ad9abe..a956b4b 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/LowercaseToStringSnapshotConfig.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/LowercaseToStringSnapshotConfig.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.config.PropertyResolvingSnapshotConfig; import io.github.finoid.snapshots.serializers.SnapshotSerializer; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/MyFirstSnapshotTest.java similarity index 94% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/MyFirstSnapshotTest.java index 5e9d2f5..709764d 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/MyFirstSnapshotTest.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/MyFirstSnapshotTest.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.Expect; import io.github.finoid.snapshots.annotations.SnapshotName; diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/TestObject.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/TestObject.java similarity index 74% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/TestObject.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/TestObject.java index 75fa794..a69b2d3 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/TestObject.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/TestObject.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; public class TestObject { @Override diff --git a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/UppercaseToStringSerializer.java similarity index 92% rename from snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/UppercaseToStringSerializer.java index ecdbc53..9d64ee2 100644 --- a/snapshot-testing-junit5/src/test/java/io/github/finoid/snapshots/docs/UppercaseToStringSerializer.java +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/UppercaseToStringSerializer.java @@ -1,4 +1,4 @@ -package io.github.finoid.snapshots.docs; +package io.github.finoid.snapshots.junit6.docs; import io.github.finoid.snapshots.Snapshot; import io.github.finoid.snapshots.SnapshotSerializerContext; diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomFrameworkExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomFrameworkExample.snap new file mode 100644 index 0000000..f744371 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomFrameworkExample.snap @@ -0,0 +1,3 @@ +io.github.finoid.snapshots.junit6.docs.CustomFrameworkExample.shouldMatchSnapshotOne=[ +Hello World +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomSnapshotConfigExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomSnapshotConfigExample.snap new file mode 100644 index 0000000..43b9767 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomSnapshotConfigExample.snap @@ -0,0 +1 @@ +io.github.finoid.snapshots.junit6.docs.CustomSnapshotConfigExample.myTest=hello world \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomSnapshotContextConfigExample.snap similarity index 100% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/__snapshots__/NestedClassTest$NestedClassWithoutSnapshot.snap rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/CustomSnapshotContextConfigExample.snap diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5Example.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5Example.snap new file mode 100644 index 0000000..466d9d6 --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5Example.snap @@ -0,0 +1,8 @@ +io.github.finoid.snapshots.junit6.docs.JUnit5Example.myTest1=[ +Hello World +] + + +io.github.finoid.snapshots.junit6.docs.JUnit5Example.myTest2=[ +Hello World Again +] \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap new file mode 100644 index 0000000..231919e --- /dev/null +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/JUnit5ResolutionHierarchyExample.snap @@ -0,0 +1,9 @@ +io.github.finoid.snapshots.junit6.docs.JUnit5ResolutionHierarchyExample.aliasMethodTest=[ + { } +] + + +io.github.finoid.snapshots.junit6.docs.JUnit5ResolutionHierarchyExample.customSerializerTest=THIS IS A SNAPSHOT OF THE TOSTRING() METHOD + + +io.github.finoid.snapshots.junit6.docs.JUnit5ResolutionHierarchyExample.lowercaseTest=this is a snapshot of the tostring() method \ No newline at end of file diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/MyFirstSnapshotContextTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/MyFirstSnapshotContextTest.snap new file mode 100644 index 0000000..e69de29 diff --git a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/MyFirstSnapshotTest.snap similarity index 56% rename from snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap rename to snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/MyFirstSnapshotTest.snap index fe0ada9..31920a7 100644 --- a/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/docs/__snapshots__/MyFirstSnapshotTest.snap +++ b/snapshot-testing-junit6/src/test/java/io/github/finoid/snapshots/junit6/docs/__snapshots__/MyFirstSnapshotTest.snap @@ -3,7 +3,7 @@ Hello World ] -io.github.finoid.snapshots.docs.MyFirstSnapshotTest.jsonSerializationTest=[ +io.github.finoid.snapshots.junit6.docs.MyFirstSnapshotTest.jsonSerializationTest=[ { "age" : 40, "name" : "John Doe"