Junit Test cases for Camunda External Task Client

I’m stuck with writing the Junit for the below code, could you please help me on this.

    public void ExtClient() {
        ExternalTaskClient client = ExternalTaskClient.create().baseUrl(baseUrl)
            .addInterceptor(new NotificationClientRequestInterceptor()).asyncResponseTimeout(asyncTimeOut)
        client.subscribe(topicName).lockDuration(100000L).handler((externalTask, externalTaskService) -> {
public class NotificationClientRequestInterceptor implements ClientRequestInterceptor {
        public void intercept(ClientRequestContext requestContext) {
            requestContext.addHeader("AuthToken", tokenAccessor.getAccessToken());

I’m new to Camunda, can anyone please help me on this.

@Ingo_Richtsmeier Could you please help me on this.

Hi @Ramanaiah,

a JUnit test for an external task client should test the handler, all other parts are tested by the external task client library.

If you separate the Lambda function into a method, you can call it in your test and provide mock objects for the task and the service and do assertions on your mocks.

Hope this helps, Ingo

@Ingo_Richtsmeier , Do we have any code snippets for it like example ,…?

Hi @Ramanaiah,

sorry, I don’t have any working code snippet available.

@Ingo_Richtsmeier , Thank you, I’m able to extract lambda expression and able to cover the code.