Search in sources :

Example 6 with ClientProperties

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());
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SocialMessage(com.faforever.client.remote.domain.SocialMessage) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Example 7 with ClientProperties

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());
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Example 8 with ClientProperties

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();
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) Before(org.junit.Before)

Example 9 with ClientProperties

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);
}
Also used : Path(java.nio.file.Path) ClientProperties(com.faforever.client.config.ClientProperties) Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Aggregations

ClientProperties (com.faforever.client.config.ClientProperties)9 Before (org.junit.Before)9 CountDownLatch (java.util.concurrent.CountDownLatch)4 Preferences (com.faforever.client.preferences.Preferences)3 Website (com.faforever.client.config.ClientProperties.Website)1 LeaderboardEntry (com.faforever.client.leaderboard.LeaderboardEntry)1 Player (com.faforever.client.player.Player)1 LoginPrefs (com.faforever.client.preferences.LoginPrefs)1 GameInfoMessage (com.faforever.client.remote.domain.GameInfoMessage)1 SocialMessage (com.faforever.client.remote.domain.SocialMessage)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)1 Pane (javafx.scene.layout.Pane)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1