use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.
the class PircBotXChatServiceTest method setUp.
@Before
public void setUp() throws Exception {
ClientProperties clientProperties = new ClientProperties();
clientProperties.getIrc().setHost(LOOPBACK_ADDRESS.getHostAddress()).setPort(IRC_SERVER_PORT).setDefaultChannel(DEFAULT_CHANNEL_NAME).setReconnectDelay(100);
instance = new PircBotXChatService(preferencesService, userService, taskService, fafService, i18n, pircBotXFactory, threadPoolExecutor, eventBus, clientProperties, playerService);
botShutdownLatch = new CountDownLatch(1);
preferences.getChat().setChatColorMode(CUSTOM);
when(userService.getUsername()).thenReturn(CHAT_USER_NAME);
when(userService.getPassword()).thenReturn(CHAT_PASSWORD);
when(defaultChannel.getName()).thenReturn(DEFAULT_CHANNEL_NAME);
when(otherChannel.getName()).thenReturn(OTHER_CHANNEL_NAME);
when(pircBotX.getConfiguration()).thenReturn(configuration);
when(pircBotX.sendIRC()).thenReturn(outputIrc);
when(pircBotX.getUserChannelDao()).thenReturn(userChannelDao);
doAnswer(invocation -> {
WaitForAsyncUtils.async(() -> ((Runnable) invocation.getArgument(0)).run());
return null;
}).when(threadPoolExecutor).execute(any(Runnable.class));
doAnswer((InvocationOnMock invocation) -> {
@SuppressWarnings("unchecked") CompletableTask<Void> task = invocation.getArgument(0);
task.run();
return task;
}).when(taskService).submitTask(any());
botStartedFuture = new CompletableFuture<>();
doAnswer(invocation -> {
botStartedFuture.complete(true);
botShutdownLatch.await();
return null;
}).when(pircBotX).startBot();
when(pircBotXFactory.createPircBotX(any())).thenReturn(pircBotX);
when(preferencesService.getPreferences()).thenReturn(preferences);
when(user1.getNick()).thenReturn("user1");
when(user1.getChannels()).thenReturn(ImmutableSortedSet.of(defaultChannel));
when(user1.getUserLevels(defaultChannel)).thenReturn(ImmutableSortedSet.of(UserLevel.VOICE));
when(user2.getNick()).thenReturn("user2");
when(user2.getChannels()).thenReturn(ImmutableSortedSet.of(defaultChannel));
when(user2.getUserLevels(defaultChannel)).thenReturn(ImmutableSortedSet.of(UserLevel.VOICE));
chatUser1 = instance.getOrCreateChatUser(user1);
chatUser2 = instance.getOrCreateChatUser(user2);
instance.postConstruct();
verify(fafService).addOnMessageListener(eq(SocialMessage.class), socialMessageListenerCaptor.capture());
}
use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.
the class GameServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
junitPlayer = PlayerBuilder.create("JUnit").defaultValues().get();
ClientProperties clientProperties = new ClientProperties();
clientProperties.getReplay().setLocalServerPort(LOCAL_REPLAY_PORT);
instance = new GameServiceImpl(clientProperties, fafService, forgedAllianceService, mapService, preferencesService, gameUpdater, notificationService, i18n, executor, playerService, reportingService, eventBus, iceAdapter, modService, platformService, externalReplayInfoGenerator);
instance.replayService = replayService;
Preferences preferences = new Preferences();
preferences.getForgedAlliance().setPort(GAME_PORT);
when(preferencesService.getPreferences()).thenReturn(preferences);
when(fafService.connectionStateProperty()).thenReturn(new SimpleObjectProperty<>());
when(replayService.startReplayServer(anyInt())).thenReturn(CompletableFuture.completedFuture(null));
when(iceAdapter.start()).thenReturn(CompletableFuture.completedFuture(GPG_PORT));
when(playerService.getCurrentPlayer()).thenReturn(Optional.of(junitPlayer));
doAnswer(invocation -> {
try {
((Runnable) invocation.getArgument(0)).run();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}).when(executor).execute(any());
instance.postConstruct();
verify(fafService).addOnMessageListener(eq(GameInfoMessage.class), gameInfoMessageListenerCaptor.capture());
}
use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.
the class MapServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
ClientProperties clientProperties = new ClientProperties();
clientProperties.getVault().setMapPreviewUrlFormat("http://127.0.0.1:65534/preview/%s/%s");
instance = new MapServiceImpl(preferencesService, taskService, applicationContext, fafService, assetService, i18n, uiService, clientProperties);
mapsDirectory = gameDirectory.newFolder("maps").toPath();
when(preferencesService.getPreferences()).thenReturn(preferences);
when(preferences.getForgedAlliance()).thenReturn(forgedAlliancePrefs);
when(forgedAlliancePrefs.getCustomMapsDirectory()).thenReturn(customMapsDirectory.getRoot().toPath());
when(forgedAlliancePrefs.customMapsDirectoryProperty()).thenReturn(customMapsDirectoryProperty);
when(forgedAlliancePrefs.getPath()).thenReturn(gameDirectory.getRoot().toPath());
when(forgedAlliancePrefs.pathProperty()).thenReturn(new SimpleObjectProperty<>());
doAnswer(invocation -> {
@SuppressWarnings("unchecked") CompletableTask<Void> task = invocation.getArgument(0);
WaitForAsyncUtils.asyncFx(task);
task.getFuture().get();
return task;
}).when(taskService).submitTask(any());
instance.postConstruct();
}
use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.
the class GameBinariesUpdateTaskTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
instance = new GameBinariesUpdateTaskImpl(i18n, preferencesService, new ClientProperties());
Path faPath = faDirectory.getRoot().toPath();
java.nio.file.Files.createDirectories(faPath.resolve("bin"));
Preferences preferences = new Preferences();
preferences.getForgedAlliance().setPath(faPath);
when(preferencesService.getFafBinDirectory()).thenReturn(fafBinDirectory.getRoot().toPath());
when(preferencesService.getPreferences()).thenReturn(preferences);
}
Aggregations