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);
}
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);
}
Aggregations