New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing Unit testing for sdk functions #617
Comments
Hello @sanjayshrestha1 , One of the samples with the mocked responses for example: |
Hi @sergiishamrai-okta, I am trying to run the okta-sdk-java in my machine but there is no class file named DefaultClient imported which is extended from MockClient class. |
Hi @sanjayshrestha1, |
The pom file contains the com.okta.sdk as defined in the prerequisites. I have also tried to replicate the code in java for unit test but instead of getting the mocked data from json file as mentioned in https://github.com/okta/okta-sdk-java/blob/master/impl/src/test/groovy/com/okta/sdk/impl/resource/log/LogsTest.groovy this link it is getting from the users from the specified client configured via baseurl and apikey. I just want to have the mock object from json file instead of from the api calling using client information. |
It seems that the support here links to files contained in modules not available with the default prerequisite dependencies for the Okta Java SDK. We have the same problem and question on how to get the Okta API Calls isolated, e.g. via Mockito, returning User or UserList objects. To be able to create those objects directly, a client is needed. If we would use Mockito to isolate calls, then it must be possible to say something like: Or something like that: final Client clientStub = Mockito.mock(Client.class); But it is still not possible to create objects to test logic of the own coding. An additional API should be provided to get better support for unit testing. |
I wanted to perform Unit Test the function which ultimately calls the sdk of okta so how can I mock the response for those sdk methods.
If there is any link that I could refer that would be great and any response is appreciated.
The text was updated successfully, but these errors were encountered: