Search in sources :

Example 1 with ADPBootstrap

use of com.alessiodp.core.common.bootstrap.ADPBootstrap 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 2 with ADPBootstrap

use of com.alessiodp.core.common.bootstrap.ADPBootstrap 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)

Aggregations

ADPPlugin (com.alessiodp.core.common.ADPPlugin)2 ADPBootstrap (com.alessiodp.core.common.bootstrap.ADPBootstrap)2 LoggerManager (com.alessiodp.core.common.logging.LoggerManager)2 OfflineUser (com.alessiodp.core.common.user.OfflineUser)2 ColorManager (com.alessiodp.parties.common.parties.ColorManager)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2