ValueResourceNameValidator { public static void validate(@NonNull String resourceName, @NonNull ResourceType resourceType, @Nullable File file) throws MergingException { String error = getErrorText(resourceName, resourceType); if (error != null) { MergingException.Builder exception = MergingException.withMessage(error); if (file != null) { exception.withFile(file); } throw exception.build(); } } private  ValueResourceNameValidator(); static void validate(@NonNull String resourceName, @NonNull ResourceType resourceType,
            @Nullable File file); @Nullable static String getErrorText(@NonNull String fullResourceName,
            @Nullable ResourceType resourceType);  }
@Test public void validate() { String errorMessage = null; try { ValueResourceNameValidator.validate(mResourceName, mResourceType, mSourceFile); } catch (MergingException e) { errorMessage = e.getMessage(); } FileResourceNameValidatorTest.assertErrorMessageCorrect( mExpectedErrorMessage, errorMessage, mSourceFile); }