Search in sources :

Example 1 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class CreateGameControllerTest method testSelectLastOrDefaultSelectLast.

@Test
public void testSelectLastOrDefaultSelectLast() {
    FeaturedMod featuredMod = FeaturedModBeanBuilder.create().defaultValues().technicalName("last").get();
    FeaturedMod featuredMod2 = FeaturedModBeanBuilder.create().defaultValues().technicalName(KnownFeaturedMod.DEFAULT.getTechnicalName()).get();
    preferences.setLastGameType("last");
    when(modService.getFeaturedMods()).thenReturn(completedFuture(asList(featuredMod, featuredMod2)));
    WaitForAsyncUtils.asyncFx(() -> instance.initialize());
    WaitForAsyncUtils.waitForFxEvents();
    assertThat(instance.featuredModListView.getSelectionModel().getSelectedItem(), is(featuredMod));
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 2 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class CreateGameControllerTest method testInitGameTypeComboBoxPostPopulated.

@Test
public void testInitGameTypeComboBoxPostPopulated() {
    FeaturedMod featuredMod = FeaturedModBeanBuilder.create().defaultValues().get();
    when(modService.getFeaturedMods()).thenReturn(completedFuture(singletonList(featuredMod)));
    WaitForAsyncUtils.asyncFx(() -> instance.initialize());
    WaitForAsyncUtils.waitForFxEvents();
    assertThat(instance.featuredModListView.getItems(), hasSize(1));
    assertThat(instance.featuredModListView.getItems().get(0), is(featuredMod));
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 3 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class ReplayDetailControllerTest method onDownloadMoreInfoClicked.

@Test
public void onDownloadMoreInfoClicked() throws Exception {
    when(replayService.getSize(anyInt())).thenReturn(CompletableFuture.completedFuture(1024));
    Replay replay = new Replay();
    Review review = new Review();
    review.setPlayer(new Player("junit"));
    replay.getReviews().setAll(FXCollections.observableArrayList(review));
    replay.setValidity(Validity.VALID);
    replay.setFeaturedMod(new FeaturedMod());
    instance.setReplay(replay);
    Path tmpPath = Paths.get("foo.tmp");
    when(replayService.downloadReplay(replay.getId())).thenReturn(CompletableFuture.completedFuture(tmpPath));
    instance.onDownloadMoreInfoClicked();
    verify(replayService).enrich(replay, tmpPath);
    assertThat(instance.optionsTable.isVisible(), is(true));
    assertThat(instance.chatTable.isVisible(), is(true));
}
Also used : Path(java.nio.file.Path) Player(com.faforever.client.player.Player) Review(com.faforever.client.vault.review.Review) FeaturedMod(com.faforever.client.mod.FeaturedMod) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 4 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class CreateGameControllerTest method testSelectLastOrDefaultSelectDefault.

@Test
public void testSelectLastOrDefaultSelectDefault() {
    FeaturedMod featuredMod = FeaturedModBeanBuilder.create().defaultValues().technicalName("something").get();
    FeaturedMod featuredMod2 = FeaturedModBeanBuilder.create().defaultValues().technicalName(KnownFeaturedMod.DEFAULT.getTechnicalName()).get();
    preferences.setLastGameType(null);
    when(modService.getFeaturedMods()).thenReturn(completedFuture(asList(featuredMod, featuredMod2)));
    WaitForAsyncUtils.asyncFx(() -> instance.initialize());
    WaitForAsyncUtils.waitForFxEvents();
    assertThat(instance.featuredModListView.getSelectionModel().getSelectedItem(), is(featuredMod2));
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 5 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class GameServiceImplTest method testStartSearchLadder1v1.

@Test
public void testStartSearchLadder1v1() throws Exception {
    GameLaunchMessage gameLaunchMessage = new GameLaunchMessage();
    gameLaunchMessage.setMod("ladder1v1");
    gameLaunchMessage.setUid(123);
    gameLaunchMessage.setArgs(emptyList());
    gameLaunchMessage.setMapname("scmp_037");
    FeaturedMod featuredMod = FeaturedModBeanBuilder.create().defaultValues().get();
    when(fafService.startSearchLadder1v1(CYBRAN, GAME_PORT)).thenReturn(CompletableFuture.completedFuture(gameLaunchMessage));
    when(gameUpdater.update(featuredMod, null, Collections.emptyMap(), Collections.emptySet())).thenReturn(CompletableFuture.completedFuture(null));
    when(mapService.isInstalled("scmp_037")).thenReturn(false);
    when(mapService.download("scmp_037")).thenReturn(CompletableFuture.completedFuture(null));
    when(modService.getFeaturedMod(LADDER_1V1.getTechnicalName())).thenReturn(CompletableFuture.completedFuture(featuredMod));
    CompletableFuture<Void> future = instance.startSearchLadder1v1(CYBRAN).toCompletableFuture();
    verify(fafService).startSearchLadder1v1(CYBRAN, GAME_PORT);
    verify(mapService).download("scmp_037");
    verify(replayService).startReplayServer(123);
    verify(forgedAllianceService, timeout(100)).startGame(eq(123), eq(CYBRAN), eq(asList("/team", "1", "/players", "2")), eq(RatingMode.LADDER_1V1), anyInt(), eq(LOCAL_REPLAY_PORT), eq(false), eq(junitPlayer));
    assertThat(future.get(TIMEOUT, TIME_UNIT), is(nullValue()));
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

FeaturedMod (com.faforever.client.mod.FeaturedMod)9 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)6 Test (org.junit.Test)6 Path (java.nio.file.Path)2 GameTooltipController (com.faforever.client.game.GameTooltipController)1 KnownFeaturedMod (com.faforever.client.game.KnownFeaturedMod)1 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)1 Player (com.faforever.client.player.Player)1 GameLaunchMessage (com.faforever.client.remote.domain.GameLaunchMessage)1 Review (com.faforever.client.vault.review.Review)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 SneakyThrows (lombok.SneakyThrows)1