File tree Expand file tree Collapse file tree
main/java/net/datafaker/service
test/java/net/datafaker/providers/base Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,8 +106,9 @@ private FakeValuesInterface getCachedFakeValue(SingletonLocale locale) {
106106 * @param path path to a file with YAML structure
107107 * @throws IllegalArgumentException in case of invalid path
108108 */
109- public void addPath (Locale locale , @ Nullable Path path ) {
109+ public void addPath (Locale locale , Path path ) {
110110 requireNonNull (locale );
111+ //noinspection ConstantValue
111112 if (path == null || Files .notExists (path ) || Files .isDirectory (path ) || !Files .isReadable (path )) {
112113 throw new IllegalArgumentException ("Path should be an existing readable file: \" %s\" " .formatted (path ));
113114 }
Original file line number Diff line number Diff line change @@ -70,15 +70,18 @@ public String bee() {
7070 }
7171
7272 @ Test
73+ @ SuppressWarnings ("DataFlowIssue" )
7374 void addNullExistingPath () {
7475 assertThatThrownBy (() -> new BaseFaker ().addPath (Locale .ENGLISH , null ))
75- .isInstanceOf (IllegalArgumentException .class );
76+ .isInstanceOf (IllegalArgumentException .class )
77+ .hasMessage ("Path should be an existing readable file: \" null\" " );
7678 }
7779
7880 @ Test
7981 void addNonExistingPath () {
8082 assertThatThrownBy (() -> new BaseFaker ().addPath (Locale .ENGLISH , Paths .get ("non-existing-file" )))
81- .isInstanceOf (IllegalArgumentException .class );
83+ .isInstanceOf (IllegalArgumentException .class )
84+ .hasMessage ("Path should be an existing readable file: \" non-existing-file\" " );
8285 }
8386
8487 @ RepeatedTest (10 )
You can’t perform that action at this time.
0 commit comments