Search in sources :

Example 1 with ColorManager

use of com.alessiodp.parties.common.parties.ColorManager in project Parties by AlessioDP.

the class MigrationsTest method setUp.

@BeforeAll
public static void setUp(@TempDir Path tempDir) {
    LoggerManager mockLoggerManager = mock(LoggerManager.class);
    when(mockPlugin.getLoggerManager()).thenReturn(mockLoggerManager);
    when(mockPlugin.getPluginFallbackName()).thenReturn("parties");
    when(mockPlugin.getFolder()).thenReturn(tempDir);
    when(mockPlugin.getResource(anyString())).thenAnswer((mock) -> ClassLoader.getSystemResourceAsStream(mock.getArgument(0)));
    when(mockLoggerManager.isDebugEnabled()).thenReturn(true);
    // Mock managers for player/party initialization
    ColorManager mockColorManager = mock(ColorManager.class);
    when(mockPlugin.getColorManager()).thenReturn(mockColorManager);
    when(mockColorManager.searchColorByName(anyString())).thenReturn(null);
    PlayerManager mockPlayerManager = mock(PlayerManager.class);
    when(mockPlugin.getPlayerManager()).thenReturn(mockPlayerManager);
    when(mockPlayerManager.initializePlayer(any())).thenAnswer((mock) -> SQLDispatcherTest.initializePlayer(mockPlugin, mock.getArgument(0)));
    PartyManager mockPartyManager = mock(PartyManager.class);
    when(mockPlugin.getPartyManager()).thenReturn(mockPartyManager);
    when(mockPartyManager.initializeParty(any())).thenAnswer((mock) -> SQLDispatcherTest.initializeParty(mockPlugin, mock.getArgument(0)));
    // 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 = Mockito.mockStatic(ADPPlugin.class);
    when(ADPPlugin.getInstance()).thenReturn(mockPlugin);
}
Also used : PlayerManager(com.alessiodp.parties.common.players.PlayerManager) PartyManager(com.alessiodp.parties.common.parties.PartyManager) 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 ColorManager

use of com.alessiodp.parties.common.parties.ColorManager in project Parties by AlessioDP.

the class PartiesPlugin method postHandle.

@Override
protected void postHandle() {
    api = new ApiHandler(this, initApiOptions());
    colorManager = new ColorManager();
    cooldownManager = new CooldownManager(this);
    expManager = new ExpManager(this);
    playerUtils = new PartiesPlayerUtils(this);
    rankManager = new RankManager(this);
    getPartyManager().reload();
    getPlayerManager().reload();
    getCommandManager().setup();
    getMessenger().reload();
    getExpManager().reload();
    registerListeners();
    reloadAdpUpdater();
    getAddonManager().loadAddons();
    Parties.setApi(api);
}
Also used : PartiesPlayerUtils(com.alessiodp.parties.common.utils.PartiesPlayerUtils) ExpManager(com.alessiodp.parties.common.parties.ExpManager) ApiHandler(com.alessiodp.parties.common.api.ApiHandler) CooldownManager(com.alessiodp.parties.common.parties.CooldownManager) ColorManager(com.alessiodp.parties.common.parties.ColorManager) RankManager(com.alessiodp.parties.common.players.RankManager)

Example 3 with ColorManager

use of com.alessiodp.parties.common.parties.ColorManager 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 4 with ColorManager

use of com.alessiodp.parties.common.parties.ColorManager 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

ColorManager (com.alessiodp.parties.common.parties.ColorManager)4 ADPPlugin (com.alessiodp.core.common.ADPPlugin)3 LoggerManager (com.alessiodp.core.common.logging.LoggerManager)3 OfflineUser (com.alessiodp.core.common.user.OfflineUser)3 BeforeAll (org.junit.jupiter.api.BeforeAll)3 ADPBootstrap (com.alessiodp.core.common.bootstrap.ADPBootstrap)2 ApiHandler (com.alessiodp.parties.common.api.ApiHandler)1 CooldownManager (com.alessiodp.parties.common.parties.CooldownManager)1 ExpManager (com.alessiodp.parties.common.parties.ExpManager)1 PartyManager (com.alessiodp.parties.common.parties.PartyManager)1 PlayerManager (com.alessiodp.parties.common.players.PlayerManager)1 RankManager (com.alessiodp.parties.common.players.RankManager)1 PartiesPlayerUtils (com.alessiodp.parties.common.utils.PartiesPlayerUtils)1