RNInstabugFeatureRequestsModule extends ReactContextBaseJavaModule { @SuppressLint("WrongConstant") @ReactMethod public void setEmailFieldRequiredForFeatureRequests(final boolean isEmailRequired, final ReadableArray actionTypes) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { try { Object[] objectArray = ArrayUtil.toArray(actionTypes); String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class); int[] parsedActionTypes = new int[stringArray.length]; int i = 0; for (String action : stringArray) { parsedActionTypes[i++] = (int) ArgsRegistry.getRawValue(action); } FeatureRequests.setEmailFieldRequired(isEmailRequired, parsedActionTypes); } catch (Exception e) { e.printStackTrace(); } } }); } RNInstabugFeatureRequestsModule(ReactApplicationContext reactApplicationContext); @Nonnull @Override String getName(); @SuppressLint("WrongConstant") @ReactMethod void setEmailFieldRequiredForFeatureRequests(final boolean isEmailRequired, final ReadableArray actionTypes); @ReactMethod void show(); @ReactMethod void setEnabled(final boolean isEnabled);  }
@Test public void givenArgs$setEmailFieldRequiredForFeatureRequests_whenQuery_thenShouldCallNativeApi() { PowerMockito.mockStatic(FeatureRequests.class); PowerMockito.mockStatic(Arguments.class); PowerMockito.when(Arguments.createArray()).thenReturn(new JavaOnlyArray()); ReadableArray actionTypes = Arguments.createArray(); ((WritableArray) actionTypes).pushString("requestNewFeature"); ((WritableArray) actionTypes).pushString("addCommentToFeature"); featureRequestsModule.setEmailFieldRequiredForFeatureRequests(true, actionTypes ); int[] parsedActionTypes = new int[2]; parsedActionTypes[0] = ActionType.REQUEST_NEW_FEATURE; parsedActionTypes[1] = ActionType.ADD_COMMENT_TO_FEATURE; PowerMockito.verifyStatic(VerificationModeFactory.times(1)); FeatureRequests.setEmailFieldRequired(true, parsedActionTypes); }