Search in sources :

Example 6 with LoggerManager

use of com.alessiodp.core.common.logging.LoggerManager in project Parties by AlessioDP.

the class FileDispatcherTest method setUp.

@BeforeAll
public static void setUp(@TempDir Path tempDir) {
    ADPBootstrap mockBootstrap = mock(ADPBootstrap.class);
    LoggerManager mockLoggerManager = mock(LoggerManager.class);
    when(mockPlugin.getPluginFallbackName()).thenReturn("parties");
    when(mockPlugin.getFolder()).thenReturn(tempDir);
    when(mockPlugin.getBootstrap()).thenReturn(mockBootstrap);
    when(mockPlugin.getLoggerManager()).thenReturn(mockLoggerManager);
    when(mockPlugin.getVersion()).thenReturn("1.0.0");
    ColorManager mockColorManager = mock(ColorManager.class);
    when(mockPlugin.getColorManager()).thenReturn(mockColorManager);
    when(mockColorManager.searchColorByName(anyString())).thenReturn(null);
    // Mock debug methods
    when(mockPlugin.getResource(anyString())).thenAnswer((mock) -> ClassLoader.getSystemResourceAsStream(mock.getArgument(0)));
    when(mockLoggerManager.isDebugEnabled()).thenReturn(true);
    doAnswer((args) -> {
        System.out.println((String) args.getArgument(0));
        return null;
    }).when(mockLoggerManager).logDebug(anyString(), anyBoolean());
    doAnswer((args) -> {
        System.out.println((String) args.getArgument(0));
        return null;
    }).when(mockLoggerManager).logError(anyString());
    doAnswer((args) -> {
        ((Exception) args.getArgument(1)).printStackTrace();
        return null;
    }).when(mockLoggerManager).logError(any(), any());
    // Mock names
    OfflineUser mockOfflineUser = mock(OfflineUser.class);
    when(mockPlugin.getOfflinePlayer(any())).thenReturn(mockOfflineUser);
    when(mockOfflineUser.getName()).thenReturn("Dummy");
    staticPlugin = Mockito.mockStatic(ADPPlugin.class);
    when(ADPPlugin.getInstance()).thenReturn(mockPlugin);
}
Also used : ADPBootstrap(com.alessiodp.core.common.bootstrap.ADPBootstrap) LoggerManager(com.alessiodp.core.common.logging.LoggerManager) OfflineUser(com.alessiodp.core.common.user.OfflineUser) ColorManager(com.alessiodp.parties.common.parties.ColorManager) ADPPlugin(com.alessiodp.core.common.ADPPlugin) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 7 with LoggerManager

use of com.alessiodp.core.common.logging.LoggerManager in project Parties by AlessioDP.

the class SQLDispatcherTest method setUp.

@BeforeAll
public static void setUp() {
    ADPBootstrap mockBootstrap = mock(ADPBootstrap.class);
    LoggerManager mockLoggerManager = mock(LoggerManager.class);
    when(mockPlugin.getPluginFallbackName()).thenReturn("parties");
    when(mockPlugin.getFolder()).thenReturn(Paths.get("../testing/"));
    when(mockPlugin.getBootstrap()).thenReturn(mockBootstrap);
    when(mockPlugin.getLoggerManager()).thenReturn(mockLoggerManager);
    when(mockPlugin.getVersion()).thenReturn("1.0.0");
    ColorManager mockColorManager = mock(ColorManager.class);
    when(mockPlugin.getColorManager()).thenReturn(mockColorManager);
    when(mockColorManager.searchColorByName(anyString())).thenReturn(null);
    // Mock debug methods
    when(mockPlugin.getResource(anyString())).thenAnswer((mock) -> ClassLoader.getSystemResourceAsStream(mock.getArgument(0)));
    when(mockLoggerManager.isDebugEnabled()).thenReturn(true);
    doAnswer((args) -> {
        System.out.println((String) args.getArgument(0));
        return null;
    }).when(mockLoggerManager).logDebug(anyString(), anyBoolean());
    doAnswer((args) -> {
        ((Exception) args.getArgument(1)).printStackTrace();
        return null;
    }).when(mockLoggerManager).logError(any(), any());
    // Mock names
    OfflineUser mockOfflineUser = mock(OfflineUser.class);
    when(mockPlugin.getOfflinePlayer(any())).thenReturn(mockOfflineUser);
    when(mockOfflineUser.getName()).thenReturn("Dummy");
    ConfigMain.STORAGE_SETTINGS_GENERAL_SQL_PREFIX = "test_";
    staticPlugin = mockStatic(ADPPlugin.class);
    when(ADPPlugin.getInstance()).thenReturn(mockPlugin);
}
Also used : ADPBootstrap(com.alessiodp.core.common.bootstrap.ADPBootstrap) LoggerManager(com.alessiodp.core.common.logging.LoggerManager) OfflineUser(com.alessiodp.core.common.user.OfflineUser) ColorManager(com.alessiodp.parties.common.parties.ColorManager) ADPPlugin(com.alessiodp.core.common.ADPPlugin) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with LoggerManager

use of com.alessiodp.core.common.logging.LoggerManager in project Parties by AlessioDP.

the class CensorUtilsTest method setUp.

@BeforeAll
public static void setUp() {
    PartiesPlugin mockPlugin = mock(PartiesPlugin.class);
    LoggerManager mockLoggerManager = mock(LoggerManager.class);
    when(mockPlugin.getLoggerManager()).thenReturn(mockLoggerManager);
    when(mockLoggerManager.isDebugEnabled()).thenReturn(true);
    doAnswer((args) -> {
        System.out.println((String) args.getArgument(0));
        return null;
    }).when(mockLoggerManager).logDebug(anyString(), anyBoolean());
    staticPlugin = Mockito.mockStatic(ADPPlugin.class);
    when(ADPPlugin.getInstance()).thenReturn(mockPlugin);
}
Also used : PartiesPlugin(com.alessiodp.parties.common.PartiesPlugin) LoggerManager(com.alessiodp.core.common.logging.LoggerManager) ADPPlugin(com.alessiodp.core.common.ADPPlugin) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 9 with LoggerManager

use of com.alessiodp.core.common.logging.LoggerManager in project ADP-Core by AlessioDP.

the class MigratorTest method setUp.

@BeforeAll
public static void setUp() {
    LoggerManager mockLoggerManager = mock(LoggerManager.class);
    when(mockPlugin.getLoggerManager()).thenReturn(mockLoggerManager);
    when(mockPlugin.getFolder()).thenReturn(Paths.get("./"));
    when(mockPlugin.getResource(anyString())).thenAnswer((mock) -> ClassLoader.getSystemResourceAsStream(mock.getArgument(0)));
    when(mockLoggerManager.isDebugEnabled()).thenReturn(true);
}
Also used : LoggerManager(com.alessiodp.core.common.logging.LoggerManager) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

LoggerManager (com.alessiodp.core.common.logging.LoggerManager)9 BeforeAll (org.junit.jupiter.api.BeforeAll)8 ADPPlugin (com.alessiodp.core.common.ADPPlugin)6 OfflineUser (com.alessiodp.core.common.user.OfflineUser)4 ColorManager (com.alessiodp.parties.common.parties.ColorManager)3 ADPBootstrap (com.alessiodp.core.common.bootstrap.ADPBootstrap)2 LoginAlertsManager (com.alessiodp.core.common.players.LoginAlertsManager)1 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)1 PartyManager (com.alessiodp.parties.common.parties.PartyManager)1 PlayerManager (com.alessiodp.parties.common.players.PlayerManager)1