### Question:
ValidateUtils { @NonNull static List<String> validatePromptParams(@NonNull Mode mode, @NonNull Goldfinger.PromptParams params) { List<String> errors = new ArrayList<>(); if (!(params.dialogOwner() instanceof Fragment) && !(params.dialogOwner() instanceof FragmentActivity)) { errors.add("DialogOwner must be of instance Fragment or FragmentActivity"); } if (StringUtils.isBlankOrNull(params.title())) { errors.add("Title is required!"); } if (!params.deviceCredentialsAllowed() && StringUtils.isBlankOrNull(params.negativeButtonText())) { errors.add("NegativeButtonText is required!"); } if (params.deviceCredentialsAllowed() && mode != Mode.AUTHENTICATION) { errors.add("DeviceCredentials are allowed only for Goldfinger#authenticate method."); } return errors; } private  ValidateUtils();   }### Answer:
@Test public void auth_valid_missingOptionalParams() { Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(activity) .title(TITLE) .negativeButtonText(NEGATIVE_BUTTON_TEXT) .build(); assertTrue(ValidateUtils.validatePromptParams(Mode.AUTHENTICATION, params).isEmpty()); }
@Test public void auth_valid_negativeTextIgnoredIfDeviceCredentialsTrue() { Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(activity) .title(TITLE) .deviceCredentialsAllowed(true) .build(); assertTrue(ValidateUtils.validatePromptParams(Mode.AUTHENTICATION, params).isEmpty()); }
@Test public void decrypt_invalid_withDeviceCredentialsTrue() { Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(activity) .title(TITLE) .deviceCredentialsAllowed(true) .build(); assertEquals(1, ValidateUtils.validatePromptParams(Mode.DECRYPTION, params).size()); }
@Test public void encrypt_invalid_withDeviceCredentialsTrue() { Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(activity) .title(TITLE) .deviceCredentialsAllowed(true) .build(); assertEquals(1, ValidateUtils.validatePromptParams(Mode.ENCRYPTION, params).size()); }
@Test public void auth_invalid_emptyTitle() { Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(activity) .negativeButtonText(NEGATIVE_BUTTON_TEXT) .description(DESCRIPTION) .subtitle(SUBTITLE) .deviceCredentialsAllowed(true) .confirmationRequired(true) .build(); assertEquals(1, ValidateUtils.validatePromptParams(Mode.AUTHENTICATION, params).size()); }
@Test public void auth_invalid_negativeTextRequired() { Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(activity) .title(TITLE) .build(); assertEquals(1, ValidateUtils.validatePromptParams(Mode.AUTHENTICATION, params).size()); }
@Test public void auth_valid() { Goldfinger.PromptParams params = new Goldfinger.PromptParams.Builder(activity) .title(TITLE) .negativeButtonText(NEGATIVE_BUTTON_TEXT) .description(DESCRIPTION) .subtitle(SUBTITLE) .deviceCredentialsAllowed(true) .confirmationRequired(true) .build(); assertTrue(ValidateUtils.validatePromptParams(Mode.AUTHENTICATION, params).isEmpty()); }