TNG / ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
http://archunit.org
Apache License 2.0
3.23k stars 298 forks source link

`FieldsShould` should provide negated variants of `haveRawType` #162

Closed asbachb closed 5 years ago

asbachb commented 5 years ago

Currently I want to accomplish something like this:

fields().that().areDeclaredInClassesThat().resideInAPackage("..package..")
.should().notHaveRawType(Float.class);

Which seems to be impossible with current api.

hankem commented 5 years ago

Those syntax elements are currently still missing indeed, but you can already build on ArchConditions.not and ArchConditions.haveRawType with ArchUnit 0.10:

    fields().that().areDeclaredInClassesThat().resideInAPackage("..package..")
            .should(not(haveRawType(Float.class)));

Alternatively, the following should be equivalent as well:

    noFields().that().areDeclaredInClassesThat().resideInAPackage("..package..")
            .should().haveRawType(Float.class);