Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Feature: Create "unwrapped" overload for `hasX` if X is a value type

Aperta
#159 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
java
Ambito
tooling

Direzione di ricerca

Non è indicato alcun file sorgente né alcun test. Inizia dal percorso del plugin Maven del generatore e dal meccanismo esistente di personalizzazione dei template menzionato nell’issue, quindi esamina come vengono definiti i metodi hasX generati. Prima dell’implementazione, concorda sui pattern di costruzione dei tipi valore supportati, sui limiti dei parametri e sul fatto che gli alias basati su annotazioni rientrino o meno nell’ambito; il lavoro è considerato completato quando il comportamento scelto è specificato e coperto da test dell’output generato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

This is potentially a little vague in its broadness, but here goes.

Say we have a value class like e.g.

@Value
class AccountNumber {
    String rawValue;
}

If another class (for which we generate assertions) has a property of this type, we can assert:

assertThat(someObject).hasAccountNumber(new AccountNumber("abc"))

Nicer would be:

assertThat(someObject).hasAccountNumber("abc")

The generator could look for constructors, static _.of methods, and other popular patterns. It's not clear to me if there should be a limit on the length of the parameter list. Anyway, the desired implementation seems straight-forward:

public S hasAccountNumber(String accountNumberRawValue) {
   return hasAccountNumber(new AccountNumber(fooRawValue));
}

As an alternative, there could be an annotation like e.g.

@AssertionAlias
static Foo of(String rawValue) { ... }

On a property Foo bar, this would cause additional generation of something like

public S hasBar(String fooRawValue) {
   return hasBar(Foo.of(fooRawValue));
}

PS: This is probably easily done for specific use cases in any given project using templates, but I don't see documentation for a way to inject custom templates when using the generator through the Maven plugin.

Lingua principale
Java
Stelle
72
Fork
47
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di assertj/assertj-generator

Tutte le issue di assertj/assertj-generator

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.