use of at.pcgamingfreaks.yaml.YAMLNotInitializedException in project Bukkit_Bungee_PluginLib by GeorgH93.
the class ConfigurationTest method testSaveConfigWithError.
@Test(expected = YAMLKeyNotFoundException.class)
public void testSaveConfigWithError() throws Exception {
YAML mockedYAML = mock(YAML.class);
doThrow(new YAMLNotInitializedException()).when(mockedYAML).save((File) anyObject());
Configuration configuration = new Configuration(mockedLogger, new File(System.getProperty("user.dir")), 1);
configuration.set("NotSavedValue", false);
Field configurationYAML = Configuration.class.getDeclaredField("config");
configurationYAML.setAccessible(true);
YAML currentConfiguration = (YAML) configurationYAML.get(configuration);
configurationYAML.set(configuration, mockedYAML);
configuration.saveConfig();
configurationYAML.set(configuration, currentConfiguration);
configurationYAML.setAccessible(false);
configuration.reload();
configuration.getBool("NotSavedValue");
}
use of at.pcgamingfreaks.yaml.YAMLNotInitializedException in project Bukkit_Bungee_PluginLib by GeorgH93.
the class LanguageTest method testSave.
@Test
public void testSave() throws FileNotFoundException, NoSuchFieldException, IllegalAccessException, YAMLNotInitializedException {
File userDir = new File(System.getProperty("user.dir"));
Language language = PowerMockito.spy(new Language(mockedLogger, userDir, 1));
YAML mockedYAML = mock(YAML.class);
doThrow(new YAMLNotInitializedException()).when(mockedYAML).save(any(File.class));
Field lang = TestUtils.setAccessible(Language.class, language, "lang", mockedYAML);
language.save();
TestUtils.setUnaccessible(lang, language, false);
}
Aggregations