RNInstabugBugReportingModule extends ReactContextBaseJavaModule { @ReactMethod public void setOnSDKDismissedHandler(final Callback handler) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { try { BugReporting.setOnDismissCallback(new OnSdkDismissCallback() { @Override public void call(DismissType dismissType, ReportType reportType) { WritableMap params = Arguments.createMap(); params.putString("dismissType", dismissType.toString()); params.putString("reportType", reportType.toString()); InstabugUtil.sendEvent(getReactApplicationContext(), Constants.IBG_POST_INVOCATION_HANDLER, params); } }); } catch (java.lang.Exception exception) { exception.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 given$setOnSDKDismissedHandler_whenQuery_thenShouldSetNativeCallback() { try { PowerMockito.mockStatic(BugReporting.class); PowerMockito.mockStatic(Arguments.class); PowerMockito.mockStatic(InstabugUtil.class); PowerMockito.when(Arguments.createMap()).thenReturn(new JavaOnlyMap()); PowerMockito.doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { ((OnSdkDismissCallback) invocation.getArguments()[0]) .call(OnSdkDismissCallback.DismissType.CANCEL, OnSdkDismissCallback.ReportType.BUG); return null; } }).when(BugReporting.class, "setOnDismissCallback", Matchers.anyObject()); bugReportingModule.setOnSDKDismissedHandler(null); WritableMap params = new JavaOnlyMap(); params.putString("dismissType", OnSdkDismissCallback.DismissType.CANCEL.toString()); params.putString("reportType", OnSdkDismissCallback.ReportType.BUG.toString()); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); InstabugUtil.sendEvent(any(ReactApplicationContext.class), eq(Constants.IBG_POST_INVOCATION_HANDLER), eq(params)); } catch (Exception e) { e.printStackTrace(); } }