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

Mocking support

Aperta
#437 1 commento 4 reazioni 2 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@hemasekhar-p ci sta già lavorando.

Dal 6/2/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

priority: p3 type: feature request

Due to the design of the GenAI Client() class it isn't possible to mock it for most use cases.

For example (with Mockito):

Client clientMock = mock(Client.class);
when(clientMock.models).thenReturn(mock(Models.class));

A simple scenario such as this won't work because the models property in Client is final and can only be set through constructors that I also can't override because the class is marked as final. It might be possible to use mockito-inline but this isn't ideal for a number of reasons.

The idiomatic way for the Client class to be defined in Java is for models to be accessed via a getter which would also support basic mocking but other ways to support mocking a Client would be welcome.

Lingua principale
Java
Stelle
398
Fork
126
Merge medio
1g 12h
PR unite (30g)
71

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 googleapis/java-genai

Tutte le issue di googleapis/java-genai

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.