Search in sources :

Example 1 with AchievementDefinition

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

the class AchievementServiceImplTest method testLoadAndCacheImageUnlocked.

@Test
public void testLoadAndCacheImageUnlocked() throws Exception {
    AchievementDefinition achievementDefinition = AchievementDefinitionBuilder.create().defaultValues().get();
    Path cacheSubDir = Paths.get("achievements").resolve(AchievementState.UNLOCKED.name().toLowerCase());
    instance.getImage(achievementDefinition, UNLOCKED);
    verify(assetService).loadAndCacheImage(new URL(achievementDefinition.getUnlockedIconUrl()), cacheSubDir, null, 128, 128);
}
Also used : Path(java.nio.file.Path) URL(java.net.URL) AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition) Test(org.junit.Test)

Example 2 with AchievementDefinition

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

the class AchievementItemControllerTest method testSetAchievementDefinition.

@Test
public void testSetAchievementDefinition() throws Exception {
    AchievementDefinition achievementDefinition = AchievementDefinitionBuilder.create().defaultValues().get();
    when(achievementService.getImage(achievementDefinition, AchievementState.REVEALED)).thenReturn(new Image(getThemeFile(DEFAULT_ACHIEVEMENT_IMAGE)));
    instance.setAchievementDefinition(achievementDefinition);
    assertThat(instance.nameLabel.getText(), is(achievementDefinition.getName()));
    assertThat(instance.descriptionLabel.getText(), is(achievementDefinition.getDescription()));
    assertThat(instance.pointsLabel.getText(), is(String.format("%d", achievementDefinition.getExperiencePoints())));
    assertThat(instance.imageView.getImage(), notNullValue());
    assertThat(instance.imageView.getEffect(), is(instanceOf(ColorAdjust.class)));
    assertThat(instance.imageView.getOpacity(), is(0.5));
    assertThat(instance.progressBar.isVisible(), is(true));
}
Also used : Image(javafx.scene.image.Image) AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 3 with AchievementDefinition

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

the class AchievementUnlockedNotifierTest method newlyUnlocked.

@Test
public void newlyUnlocked() throws Exception {
    AchievementDefinition achievementDefinition = new AchievementDefinition();
    achievementDefinition.setType(AchievementType.STANDARD);
    achievementDefinition.setName("Test Achievement");
    when(achievementService.getImage(achievementDefinition, UNLOCKED)).thenReturn(mock(Image.class));
    triggerUpdatedAchievementsMessage(achievementDefinition, true);
    verify(audioService).playAchievementUnlockedSound();
    ArgumentCaptor<TransientNotification> notificationCaptor = ArgumentCaptor.forClass(TransientNotification.class);
    verify(notificationService).addNotification(notificationCaptor.capture());
    TransientNotification notification = notificationCaptor.getValue();
    assertThat(notification.getImage(), notNullValue());
    assertThat(notification.getTitle(), is("Achievement unlocked"));
    assertThat(notification.getText(), is("Test Achievement"));
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) Image(javafx.scene.image.Image) AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition) Test(org.junit.Test)

Example 4 with AchievementDefinition

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

the class AchievementUnlockedNotifierTest method alreadyUnlocked.

@Test
public void alreadyUnlocked() {
    AchievementDefinition achievementDefinition = new AchievementDefinition();
    achievementDefinition.setType(AchievementType.STANDARD);
    achievementDefinition.setName("Test Achievement");
    triggerUpdatedAchievementsMessage(achievementDefinition, false);
    verifyZeroInteractions(audioService);
    verifyZeroInteractions(notificationService);
}
Also used : AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition) Test(org.junit.Test)

Example 5 with AchievementDefinition

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

the class FafApiAccessorImplTest method testGetAchievementDefinitions.

@Test
public void testGetAchievementDefinitions() {
    AchievementDefinition achievementDefinition1 = new AchievementDefinition();
    achievementDefinition1.setId("1-2-3");
    AchievementDefinition achievementDefinition2 = new AchievementDefinition();
    achievementDefinition2.setId("2-3-4");
    List<AchievementDefinition> result = Arrays.asList(achievementDefinition1, achievementDefinition2);
    when(restOperations.getForObject(startsWith("/data/achievement"), eq(List.class))).thenReturn(result).thenReturn(emptyList());
    assertThat(instance.getAchievementDefinitions(), is(result));
}
Also used : AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition) Test(org.junit.Test)

Aggregations

AchievementDefinition (com.faforever.client.api.dto.AchievementDefinition)10 Test (org.junit.Test)8 PlayerAchievement (com.faforever.client.api.dto.PlayerAchievement)2 URL (java.net.URL)2 Path (java.nio.file.Path)2 Image (javafx.scene.image.Image)2 AchievementItemController (com.faforever.client.achievements.AchievementItemController)1 TransientNotification (com.faforever.client.notification.TransientNotification)1 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)1 Node (javafx.scene.Node)1