Giter Club home page Giter Club logo

auto-truth's Introduction

AutoTruth

GitHub Actions FOSSA Status Quality Gate Status Coverage

Generate the Truth extensions for value objects for Java 8+.

Usage

Add the @AutoTruth annotation to a custom subject class and specify a value object class.
This example uses Employee.java.

@AutoSubject(Employee.class)
class EmployeeSubject {
}

Then AutoTruth generates the AutoEmployeeSubject that is declared the following methods:

  • hasUsername(String)
  • hasId(long)
  • hasName(String)
  • hasLocation(Location)
  • isCeo()
  • isNotCeo()

You can extends the AutoEmployeeSubject as follows, if the generated methods are not enough.

@AutoSubject(Employee.class)
public class EmployeeSubject extends AutoEmployeeSubject {
    private final Employee actual;

    EmployeeSubject(FailureMetadata failureMetadata, Employee actual) {
        super(failureMetadata, actual);
        this.actual = actual;
    }

    public static EmployeeSubject assertThat(Employee actual) {
        return Truth.assertAbout(EmployeeSubject::new).that(actual);
    }
    
    public LocationSubject location() {
        final Location actual = this.actual.location();
        return check("location()").about(LocationSubject::new).that(actual);
    }
    
    @AutoSubject(Employee.Location.class)
    public static class LocationSubject {}
}

Supported types

AutoTruth supports the following types:

Primitive types

  • boolean
  • byte
  • char
  • short
  • int
  • long
  • float
  • double

Array types

  • boolean[]
  • byte[]
  • char[]
  • short[]
  • int[]
  • long[]
  • float[]
  • double[]
  • Object[]

Java8 types

  • Optional
  • OptionalInt
  • OptionalLong
  • OptionalDouble
  • Stream
  • IntStream
  • LongStream

Other JDK types

  • Enum
  • Object
  • Class
  • String
  • Iterable
  • Map

Installing

The AutoTruth packages are available on the GitHub Packages.
You need an access token to install packages in GitHub Packages.
Instructions for creating an access token is described in GitHub Help.

Gradle

repositories {
    mavenCentral()
    jcenter()
    maven {
        url 'https://maven.pkg.github.com/t28hub/auto-truth'
        credentials {
            username = 'YOUR_GITHUB_USERNAME'
            password = 'YOUR_GITHUB_TOKEN'
        }
    }
}

dependencies {
    testImplementation "com.google.truth:truth:$LATEST_TRUTH_VERSION"
    testImplementation "com.google.truth.extensions:truth-java8-extension:$LATEST_TRUTH_VERSION"
    testImplementation "io.t28.auto:auto-truth-annotations:$LATEST_VERSION"
    testAnnotationProcessor "io.t28.auto:auto-truth-processor:$LATEST_VERSION"
}

Maven

See GitHub Help.

License

FOSSA Status

auto-truth's People

Contributors

t28hub avatar renovate[bot] avatar fossabot avatar

Watchers

James Cloos avatar  avatar

auto-truth's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update actions/cache action to v4
  • Update actions/checkout action to v4
  • Update actions/setup-java action to v4
  • Update actions/upload-artifact action to v4
  • Update dependency gradle to v8
  • Update gradle/wrapper-validation-action action to v3
  • Update kotlinVersion to v2 (major) (org.jetbrains.kotlin.kapt, org.jetbrains.kotlin.jvm)
  • Update plugin org.jlleitschuh.gradle.ktlint to v12
  • Update plugin org.sonarqube to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v2
  • gradle/wrapper-validation-action v1
  • actions/setup-java v1
  • actions/cache v1
  • actions/upload-artifact v1
  • actions/upload-artifact v1
  • actions/checkout v2
  • gradle/wrapper-validation-action v1
  • actions/setup-java v1
  • actions/cache v1
  • actions/checkout v2
  • gradle/wrapper-validation-action v1
  • actions/setup-java v1
  • actions/cache v1
  • actions/upload-artifact v1
  • actions/upload-artifact v1
  • actions/checkout v2
  • gradle/wrapper-validation-action v1
  • actions/setup-java v1
  • actions/cache v1
  • actions/upload-artifact v1
.github/workflows/fossa.yml
  • actions/checkout v2
  • gradle/wrapper-validation-action v1
  • actions/setup-java v1
.github/workflows/publish.yml
  • actions/checkout v2
  • gradle/wrapper-validation-action v1
  • actions/setup-java v1
  • actions/cache v1
gradle
settings.gradle.kts
build.gradle.kts
  • javax.annotation:javax.annotation-api 1.3.2
  • com.google.code.findbugs:jsr305 3.0.2
  • com.google.truth:truth 1.0.1
  • com.google.truth.extensions:truth-java8-extension 1.0.1
  • com.google.auto.service:auto-service-annotations 1.0-rc7
  • com.google.auto.service:auto-service 1.0-rc7
  • com.squareup:javapoet 1.13.0
  • org.junit.jupiter:junit-jupiter 5.6.2
  • com.google.testing.compile:compile-testing 0.18
  • com.github.tschuchortdev:kotlin-compile-testing 1.2.9
  • com.nhaarman.mockitokotlin2:mockito-kotlin 2.2.0
annotations/build.gradle.kts
processor/build.gradle.kts
  • org.jetbrains.kotlin.jvm 1.3.72
  • org.jetbrains.kotlin.kapt 1.3.72
  • org.jlleitschuh.gradle.ktlint 9.3.0
  • io.gitlab.arturbosch.detekt 1.11.2
  • org.sonarqube 3.0
  • jacoco 0.8.5
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 6.6

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.