0

I am writing the below code using Contentstack Management SDK, and when I am writing the unit tests using Mockito framework, not able to Mock the entry.create(prodRequest).execute().

Can I get some assistance on this please, (basically how to mock the retrofit2). Here is the code snippet.

import com.contentstack.cms.Contentstack;
import com.contentstack.cms.stack.Entry;
import com.contentstack.cms.stack.Stack;
import retrofit2.Response;
Contentstack contentstack = new Contentstack.Builder().build();
Stack stack = contentstack.stack(stackApiKey, managementToken);
Entry entry = stack.contentType(contentType).entry();
try {
Response responseFromCs = entry.create(prodRequest).execute();
if (responseFromCs.isSuccessful()) {
}
  • `new Contentstack.Builder().build()` is not a mock. See https://stackoverflow.com/questions/74027324/why-are-my-mocked-methods-not-called-when-executing-a-unit-test for the problem description and solution strategies – knittl Sep 01 '23 at 16:50
  • These are not my Test class code, but the actual code which I want to Mock in my Test class. This perticular line I am looking for , how to Mock. entry.create(prodRequest).execute() – user3674968 Sep 02 '23 at 17:07

0 Answers0