Search in sources :

Example 6 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement in project downlords-faf-client by FAForever.

the class AchievementItemControllerTest method testSetPlayerAchievementUnlocked.

@Test
public void testSetPlayerAchievementUnlocked() throws Exception {
    instance.setAchievementDefinition(AchievementDefinitionBuilder.create().defaultValues().get());
    PlayerAchievement playerAchievement = PlayerAchievementBuilder.create().defaultValues().state(com.faforever.client.api.dto.AchievementState.UNLOCKED).currentSteps(50).get();
    instance.setPlayerAchievement(playerAchievement);
    assertThat(instance.imageView.getEffect(), is(nullValue()));
    assertThat(instance.imageView.getOpacity(), is(1.0));
    assertThat(instance.progressBar.isVisible(), is(true));
    assertThat(instance.progressBar.getProgress(), is(0.5));
}
Also used : PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 7 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement in project downlords-faf-client by FAForever.

the class FafApiAccessorImplTest method testGetPlayerAchievements.

@Test
@SuppressWarnings("unchecked")
public void testGetPlayerAchievements() {
    PlayerAchievement playerAchievement1 = new PlayerAchievement();
    playerAchievement1.setId("1");
    playerAchievement1.setAchievement(new AchievementDefinition().setId("1-2-3"));
    PlayerAchievement playerAchievement2 = new PlayerAchievement();
    playerAchievement2.setId("2");
    playerAchievement2.setAchievement(new AchievementDefinition().setId("2-3-4"));
    List<PlayerAchievement> result = Arrays.asList(playerAchievement1, playerAchievement2);
    when(restOperations.getForObject(anyString(), eq(List.class))).thenReturn(result).thenReturn(emptyList());
    assertThat(instance.getPlayerAchievements(123), is(result));
    verify(restOperations).getForObject("/data/playerAchievement?filter=player.id==\"123\"&page[size]=10000&page[number]=1", List.class);
}
Also used : PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition) Test(org.junit.Test)

Example 8 with PlayerAchievement

use of com.faforever.client.api.dto.PlayerAchievement in project downlords-faf-client by FAForever.

the class AchievementServiceImplTest method testGetPlayerAchievementsForAnotherUser.

@Test
public void testGetPlayerAchievementsForAnotherUser() throws Exception {
    List<PlayerAchievement> achievements = Arrays.asList(new PlayerAchievement(), new PlayerAchievement());
    when(fafService.getPlayerAchievements(PLAYER_ID)).thenReturn(CompletableFuture.completedFuture(achievements));
    List<PlayerAchievement> playerAchievements = instance.getPlayerAchievements(PLAYER_ID).toCompletableFuture().get(5, TimeUnit.SECONDS);
    assertThat(playerAchievements, hasSize(2));
    assertThat(playerAchievements, is(achievements));
    verify(fafService).getPlayerAchievements(PLAYER_ID);
}
Also used : PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) Test(org.junit.Test)

Aggregations

PlayerAchievement (com.faforever.client.api.dto.PlayerAchievement)8 Test (org.junit.Test)7 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)4 AchievementDefinition (com.faforever.client.api.dto.AchievementDefinition)2 AchievementItemController (com.faforever.client.achievements.AchievementItemController)1 Node (javafx.scene.Node)1