RNInstabugBugReportingModule extends ReactContextBaseJavaModule { @ReactMethod public void setInvocationEvents(ReadableArray invocationEventValues) { try { Object[] objectArray = ArrayUtil.toArray(invocationEventValues); String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class); final ArrayList<InstabugInvocationEvent> parsedInvocationEvents = new ArrayList<>(); for (String event : stringArray) { parsedInvocationEvents.add(ArgsRegistry.getDeserializedValue(event, InstabugInvocationEvent.class)); } MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { try { BugReporting.setInvocationEvents(parsedInvocationEvents.toArray(new InstabugInvocationEvent[0])); } catch (Exception e) { e.printStackTrace(); } } }); } catch (Exception e) { e.printStackTrace(); } } RNInstabugBugReportingModule(ReactApplicationContext reactContext); @Nonnull @Override String getName(); @ReactMethod void setEnabled(final boolean isEnabled); @TargetApi(21) @ReactMethod void setAutoScreenRecordingEnabled(final boolean autoScreenRecordingEnabled); @ReactMethod void setExtendedBugReportMode(final String extendedBugReportMode); @ReactMethod void setViewHierarchyEnabled(final boolean isEnabled); @ReactMethod void setVideoRecordingFloatingButtonPosition(final String corner); @ReactMethod void setEnabledAttachmentTypes(final boolean screenshot, final boolean extraScreenshot, final boolean
            galleryImage, final boolean screenRecording); @ReactMethod void setInvocationEvent(final String invocationEventValue); @ReactMethod void setInvocationEvents(ReadableArray invocationEventValues); @ReactMethod void setOptions(final ReadableArray optionValues); @ReactMethod void setOnInvokeHandler(final Callback onInvokeHandler); @ReactMethod void setFloatingButtonEdge(final String floatingButtonEdge, final int floatingButtonOffset); @ReactMethod void setOnSDKDismissedHandler(final Callback handler); @ReactMethod void setShakingThresholdForAndroid(final int androidThreshold); @SuppressLint("WrongConstant") @ReactMethod void setReportTypes(ReadableArray types); @ReactMethod void show(final String reportType, final ReadableArray options);  }
@Test public void givenInvocationEvent$setInvocationEvents_whenQuery_thenShouldCallNativeApiWithArgs() { PowerMockito.mockStatic(BugReporting.class); final Map<String, Object> args = new HashMap<>(); ArgsRegistry.registerInstabugInvocationEventsArgs(args); final String[] keysArray = args.keySet().toArray(new String[0]); JavaOnlyArray actualArray = new JavaOnlyArray(); for (String key : keysArray) { actualArray.pushString(key); } bugReportingModule.setInvocationEvents(actualArray); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); BugReporting.setInvocationEvents(args.values().toArray(new InstabugInvocationEvent[0])); }