Azure / Azure/azure-documentdb-java

Remove final from DTO's to support Unit Testing

Abierto
#104 1 comentario 1 reacción 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Java
Estrellas
51
Forks
52
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

As a dev,
I want to write unit tests that mock the documentClient
so that I can unit test the behaviour of my classes.

Currently this is very hard thanks to the final classes returned by the documentClient.
i.e.

```
import com.microsoft.azure.documentdb.*;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.*;

...

private void givenAResponse(List response) {
DocumentClient documentClient = mock(DocumentClient.class);
FeedResponse feedResponse = mock(FeedResponse.class);
QueryIterable queryIterable = mock(QueryIterable.class);
when(documentClient.queryDocuments(
eq(CONNECTION_LINK),
any(String.class),
any(FeedOptions.class)))
.thenReturn(feedResponse);
when(feedResponse.getQueryIterable()).thenReturn(queryIterable);
when(queryIterable.toList()).thenReturn(response);
}
```

fails with:
```
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class com.microsoft.azure.documentdb.FeedResponse
Mockito cannot mock/spy following:
- final classes
```

Please can you remove 'final' from: FeedResponse and QueryIterable?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.