PropsUtils { public static Props newProps(final Props parentProps, final String filePath) throws IOException { return (filePath == null) ? (parentProps == null ? null : new Props(parentProps)) : newProps(parentProps, new File(filePath)); } private  PropsUtils(); static Props loadPropsInDir(final File dir, final String... suffixes); static Props loadPropsInDir(final Props parent, final File dir, final String... suffixes); static Props loadProps(final Props parent, final File... propFiles); static Props loadPluginProps(final File pluginDir); static Props loadPropsInDirs(final List<File> dirs, final String... suffixes); static void loadPropsBySuffix(final File jobPath, final Props props,
      final String... suffixes); static boolean isVariableReplacementPattern(final String value); static Props resolveProps(final Props props); static Props newProps(final Props parentProps, final String filePath); static Props newProps(final Props parentProps, final File file); static String toJSONString(final Props props, final boolean localOnly); static Map<String, String> toStringMap(final Props props, final boolean localOnly); static Props fromJSONString(final String json); static Props fromHierarchicalMap(final Map<String, Object> propsMap); static Map<String, Object> toHierarchicalMap(final Props props); static String getPropertyDiff(Props oldProps, Props newProps);  }
@Test public void testNewPropsForFileNotExist() throws IOException { File file = Mockito.mock(File.class); Mockito.when(file.exists()).thenReturn(false); Props parent = new Props().setSource("test"); Props props = PropsUtils.newProps(parent, file); Assert.assertNotNull(props); Assert.assertNotNull(props.getParent()); Assert.assertEquals("test", props.getParent().getSource()); }
@Test public void testNewPropsForNullParentAndFileNotExist() throws IOException { File file = Mockito.mock(File.class); Mockito.when(file.exists()).thenReturn(false); Props props = PropsUtils.newProps(null, file); Assert.assertNull(props); }