Unable to access java method having arguments using java interop in karate (methods with no arguments are accessed fine)

72 views Asked by At

This is my Java Class (for the sake of simplicity, omitting few obvious details)

package com.abc.hstools.core.services;

import com.abc.hstools.core.css.MatchListResponse;

public class ConsumptionSportsService {
    
    //constructor with arguments not shown

    public MatchListResponse getAllMatches() {
        //some code here
        return null;
    }

    public void overrideConcurrencyUsingEventId(String eventId, int concurrency) {
        //some code here
    }

}

This is my scenario Scenario: Verify Concurrency Widget data

  • def ConsumptionSportsService = Java.type('com.abc.hstools.core.services.ConsumptionSportsService');
  • def consumptionSportsService = new ConsumptionSportsService(consumptionPortalToken, 'pp');
  • def x = consumptionSportsService.getAllMatches();
  • consumptionSportsService.overrideConcurrencyUsingEventId('1234')

As per this response, I am able to access getAllMatches method (no arguments), but unable to access overrideConcurrencyUsingEventId method which has arguments, even though both methods exist in same class.

Apr 03, 2023 12:21:48 AM okhttp3.internal.platform.Platform log
INFO: --\> GET https://origin-consumption-portal-pp.mum.abc-labs.com/sports/v1/events/matches?status=all&limit=100
Apr 03, 2023 12:21:53 AM okhttp3.internal.platform.Platform log
INFO: \<-- 200 OK https://origin-consumption-portal-pp.mum.abc-labs.com/sports/v1/events/matches?status=all&limit=100 (4952ms, unknown-length body)
00:21:53.558 |  |  \[main\]  ERROR com.intuit.karate - Users/rohitdharap/IdeaProjects/hs-automation-tests/src/test/hstest/features/consumption/sports/ConcurrencyWidgetTest.feature:13

* consumptionSportsService.overrideConcurrencyUsingEventId('1234')
  js failed:

> > > > 

01: consumptionSportsService.overrideConcurrencyUsingEventId('1234')
\<\<\<\<
org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (overrideConcurrencyUsingEventId) on com.abc.hstools.core.services.ConsumptionSportsService@7c8d5312 failed due to: Unknown identifier: overrideConcurrencyUsingEventId

- \<js\>.:program(Unnamed:1)

I tried to refer this java interop tutorial https://github.com/karatelabs/karate#java-interop

0

There are 0 answers