Search in sources :

Example 1 with DataFolder

use of fr.xephi.authme.initialization.DataFolder in project AuthMeReloaded by AuthMe.

the class MessageFileHandlerProviderTest method shouldCreateHandler.

@Test
public void shouldCreateHandler() {
    // given
    String language = "fr";
    given(settings.getProperty(PluginSettings.MESSAGES_LANGUAGE)).willReturn(language);
    MessageFileHandlerProvider provider = Mockito.spy(handlerProvider);
    Function<String, String> fileFunction = lang -> "file_" + lang + ".txt";
    File file = new File(dataFolder, "some_file.txt");
    doReturn(file).when(provider).initializeFile(language, fileFunction);
    // when
    MessageFileHandler handler = provider.initializeHandler(fileFunction);
    // then
    assertThat(handler, not(nullValue()));
    verify(settings).getProperty(PluginSettings.MESSAGES_LANGUAGE);
    verify(provider).initializeFile(language, fileFunction);
}
Also used : BeforeClass(org.junit.BeforeClass) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Matchers.not(org.hamcrest.Matchers.not) DataFolder(fr.xephi.authme.initialization.DataFolder) Function(java.util.function.Function) Assert.assertThat(org.junit.Assert.assertThat) TestHelper.getJarFile(fr.xephi.authme.TestHelper.getJarFile) Files(com.google.common.io.Files) BDDMockito.given(org.mockito.BDDMockito.given) BeforeInjecting(ch.jalu.injector.testing.BeforeInjecting) Matchers.nullValue(org.hamcrest.Matchers.nullValue) TestHelper(fr.xephi.authme.TestHelper) PluginSettings(fr.xephi.authme.settings.properties.PluginSettings) Mockito.doReturn(org.mockito.Mockito.doReturn) Description(org.hamcrest.Description) Settings(fr.xephi.authme.settings.Settings) InjectDelayed(ch.jalu.injector.testing.InjectDelayed) Test(org.junit.Test) IOException(java.io.IOException) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) Mockito(org.mockito.Mockito) Rule(org.junit.Rule) Matcher(org.hamcrest.Matcher) Matchers.equalTo(org.hamcrest.Matchers.equalTo) TemporaryFolder(org.junit.rules.TemporaryFolder) DelayedInjectionRunner(ch.jalu.injector.testing.DelayedInjectionRunner) TestHelper.getJarFile(fr.xephi.authme.TestHelper.getJarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

BeforeInjecting (ch.jalu.injector.testing.BeforeInjecting)1 DelayedInjectionRunner (ch.jalu.injector.testing.DelayedInjectionRunner)1 InjectDelayed (ch.jalu.injector.testing.InjectDelayed)1 Files (com.google.common.io.Files)1 TestHelper (fr.xephi.authme.TestHelper)1 TestHelper.getJarFile (fr.xephi.authme.TestHelper.getJarFile)1 DataFolder (fr.xephi.authme.initialization.DataFolder)1 Settings (fr.xephi.authme.settings.Settings)1 PluginSettings (fr.xephi.authme.settings.properties.PluginSettings)1 File (java.io.File)1 IOException (java.io.IOException)1 Function (java.util.function.Function)1 Description (org.hamcrest.Description)1 Matcher (org.hamcrest.Matcher)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1 Matchers.not (org.hamcrest.Matchers.not)1 Matchers.nullValue (org.hamcrest.Matchers.nullValue)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1 Assert.assertThat (org.junit.Assert.assertThat)1 BeforeClass (org.junit.BeforeClass)1