Azure / azure-cosmosdb-java

Java Async SDK for SQL API of Azure Cosmos DB
MIT License
54 stars 61 forks source link

can't mock com.microsoft.azure.cosmosdb.ResourceResponse as it's final class #138

Closed rgampa closed 5 years ago

rgampa commented 5 years ago

Getting below error when mocking ResourceResponse, using sdk version 2.4.5. I saw FeedResponse doesn't have final keyword, can you make it same for ResourceResponse?

FAILED CONFIGURATION: @BeforeMethod setup
org.mockito.exceptions.base.MockitoException: 
Cannot mock/spy class com.microsoft.azure.cosmosdb.ResourceResponse
Mockito cannot mock/spy because :
 - final class
rgampa commented 5 years ago

Found workaround to mock final class here: https://www.baeldung.com/mockito-final. However it will be nice if final is removed from classes where consumer have to mock for unit testing.

christopheranderson commented 5 years ago

Done in V3

ghost commented 2 years ago

Actually, I don't think you want to remove final for testing purpose only. See: https://ocramius.github.io/blog/when-to-declare-classes-final/