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);
}
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));
}
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"));
}
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);
}
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));
}
Aggregations