use of com.faforever.api.data.domain.PlayerAchievement in project faf-java-api by FAForever.
the class EventsServiceTest method incrementExisting.
/**
* Tests whether an achievement is properly incremented if it already existed.
*/
@Test
public void incrementExisting() throws Exception {
mockAchievement("111", AchievementType.INCREMENTAL, 10);
when(playerAchievementRepository.findOneByAchievementIdAndPlayerId("111", PLAYER_ID)).thenReturn(Optional.of(createPlayerAchievement(4, REVEALED)));
instance.increment(PLAYER_ID, "111", 3);
PlayerAchievement playerAchievement = captureSaveEvent();
assertThat(playerAchievement.getCurrentSteps(), is(7));
assertThat(playerAchievement.getState(), is(REVEALED));
}
use of com.faforever.api.data.domain.PlayerAchievement in project faf-java-api by FAForever.
the class EventsServiceTest method setStepsAtLeastFirstTime.
/**
* Tests whether an achievement's steps are properly set to the specified value if it's being set for the first time.
*/
@Test
public void setStepsAtLeastFirstTime() throws Exception {
mockAchievement("111", AchievementType.INCREMENTAL, 10);
when(playerAchievementRepository.findOneByAchievementIdAndPlayerId("111", PLAYER_ID)).thenReturn(Optional.empty());
instance.setStepsAtLeast(PLAYER_ID, "111", 4);
PlayerAchievement playerAchievement = captureSaveEvent();
assertThat(playerAchievement.getCurrentSteps(), is(4));
assertThat(playerAchievement.getState(), is(REVEALED));
}
use of com.faforever.api.data.domain.PlayerAchievement in project faf-java-api by FAForever.
the class EventsServiceTest method setStepsAtLeastExistingLessSteps.
/**
* Tests whether an achievement's steps are not updated if the existing steps are higher than the new steps.
*/
@Test
public void setStepsAtLeastExistingLessSteps() throws Exception {
mockAchievement("111", AchievementType.INCREMENTAL, 10);
when(playerAchievementRepository.findOneByAchievementIdAndPlayerId("111", PLAYER_ID)).thenReturn(Optional.of(createPlayerAchievement(5, REVEALED)));
instance.setStepsAtLeast(PLAYER_ID, "111", 4);
PlayerAchievement playerAchievement = captureSaveEvent();
assertThat(playerAchievement.getCurrentSteps(), is(5));
assertThat(playerAchievement.getState(), is(REVEALED));
}
use of com.faforever.api.data.domain.PlayerAchievement in project faf-java-api by FAForever.
the class EventsServiceTest method unlockFirstTime.
/**
* Tests whether a PlayerAchievement is properly created and unlocked if it's being unlocked the first time.
*/
@Test
public void unlockFirstTime() throws Exception {
mockAchievement("111", AchievementType.STANDARD, null);
when(playerAchievementRepository.findOneByAchievementIdAndPlayerId("111", PLAYER_ID)).thenReturn(Optional.empty());
instance.unlock(PLAYER_ID, "111");
PlayerAchievement playerAchievement = captureSaveEvent();
assertThat(playerAchievement.getCurrentSteps(), is(CoreMatchers.nullValue()));
assertThat(playerAchievement.getState(), is(UNLOCKED));
}
use of com.faforever.api.data.domain.PlayerAchievement in project faf-java-api by FAForever.
the class EventsServiceTest method incrementFirstTime.
/**
* Tests whether an achievement is properly created and incremented if it's being incremented for the first time.
*/
@Test
public void incrementFirstTime() throws Exception {
mockAchievement("111", AchievementType.INCREMENTAL, 10);
when(playerAchievementRepository.findOneByAchievementIdAndPlayerId("111", PLAYER_ID)).thenReturn(Optional.empty());
instance.increment(PLAYER_ID, "111", 3);
PlayerAchievement playerAchievement = captureSaveEvent();
assertThat(playerAchievement.getCurrentSteps(), is(3));
assertThat(playerAchievement.getState(), is(REVEALED));
}
Aggregations