use of com.faforever.server.entity.MapStats in project faf-java-server by FAForever.
the class MapServiceTest method timesPlayedIsIncreasedCorrectly.
@Test
public void timesPlayedIsIncreasedCorrectly() {
Map map = new Map().setId(1);
MapStats features = instance.getMapStats(map);
assertThat(features.getId(), is(1));
assertThat(features.getTimesPlayed(), is(41));
instance.incrementTimesPlayed(map);
verify(mapStatsRepository).save(features);
features = instance.getMapStats(map);
assertThat(features.getId(), is(1));
assertThat(features.getTimesPlayed(), is(42));
verifyZeroInteractions(mapVersionRepository);
verifyZeroInteractions(ladder1v1MapRepository);
}
use of com.faforever.server.entity.MapStats in project faf-java-server by FAForever.
the class MapServiceTest method setUp.
@Before
public void setUp() {
mapVersion = new MapVersion().setId(1).setFilename(MAP_NAME);
when(mapVersionRepository.findByFilenameIgnoreCase(MAP_NAME)).thenReturn(Optional.of(mapVersion));
when(mapVersionRepository.findOne(1)).thenReturn(mapVersion);
MapStats features = new MapStats().setId(1).setTimesPlayed(41);
when(mapStatsRepository.findOne(1)).thenReturn(features);
when(mapStatsRepository.save(any(MapStats.class))).thenAnswer(context -> context.getArguments()[0]);
instance = new MapService(mapVersionRepository, ladder1v1MapRepository, mapStatsRepository);
}
use of com.faforever.server.entity.MapStats in project faf-java-server by FAForever.
the class MapService method incrementTimesPlayed.
@Transactional
public void incrementTimesPlayed(Map map) {
MapStats features = getMapStats(map);
features.incrementTimesPlayed();
mapStatsRepository.save(features);
}
use of com.faforever.server.entity.MapStats in project faf-java-server by FAForever.
the class MapService method getMapStats.
@Transactional
public MapStats getMapStats(Map map) {
MapStats features = mapStatsRepository.findOne(map.getId());
if (features == null) {
features = new MapStats().setId(map.getId());
features = mapStatsRepository.save(features);
}
return features;
}
use of com.faforever.server.entity.MapStats in project faf-java-server by FAForever.
the class MapServiceTest method timesPlayedIsInitializedWithZero.
@Test
public void timesPlayedIsInitializedWithZero() {
int newId = 1342342;
Map map = new Map().setId(newId);
MapStats features = instance.getMapStats(map);
assertThat(features.getId(), is(newId));
assertThat(features.getTimesPlayed(), is(0));
verify(mapStatsRepository).save(features);
verifyZeroInteractions(mapVersionRepository);
verifyZeroInteractions(ladder1v1MapRepository);
}
Aggregations