RNInstabugBugReportingModule extends ReactContextBaseJavaModule { @SuppressLint("WrongConstant") @ReactMethod public void setReportTypes(ReadableArray types) { Object[] objectArray = ArrayUtil.toArray(types); String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class); final int[] parsedReportTypes = new int[stringArray.length]; for (int i = 0; i < stringArray.length; i++) { parsedReportTypes[i] = (int) ArgsRegistry.getRawValue(stringArray[i]); } MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { try { BugReporting.setReportTypes(parsedReportTypes); } 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 givenArray$setReportTypes_whenQuery_thenShouldCallNativeApiWithEnumArgs() { PowerMockito.mockStatic(BugReporting.class); final Map<String, Object> args = new HashMap<>(); ArgsRegistry.registerInstabugReportTypesArgs(args); final String[] keysArray = args.keySet().toArray(new String[0]); JavaOnlyArray actualArray = new JavaOnlyArray(); actualArray.pushString(keysArray[0]); actualArray.pushString(keysArray[1]); bugReportingModule.setReportTypes(actualArray); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); int type1 = (int) args.get(keysArray[0]); int type2 = (int) args.get(keysArray[1]); BugReporting.setReportTypes(type1, type2); }