Search in sources :

Example 1 with LocaleService

use of pokeraidbot.domain.config.LocaleService in project pokeraidbot by magnusmickelsson.

the class GymRepositoryTest method setUp.

@Before
public void setUp() throws Exception {
    UserConfigRepository userConfigRepository = mock(UserConfigRepository.class);
    when(userConfigRepository.findOne(any(String.class))).thenReturn(null);
    localeService = new LocaleService("sv", userConfigRepository);
    final Config dalarnaConfig = new Config("dalarna", "dalarna");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("dalarna")).thenReturn(dalarnaConfig);
    final Config uppsalaConfig = new Config("uppsala", "uppsala");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("uppsala")).thenReturn(uppsalaConfig);
    final Config angelholmConfig = new Config("ängelholm", "ängelholm");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("ängelholm")).thenReturn(angelholmConfig);
    final Config luleConfig = new Config("luleå", "luleå");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("luleå")).thenReturn(luleConfig);
    final Config umeConfig = new Config("umeå", "umeå");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("umeå")).thenReturn(umeConfig);
    final Config vannasConfig = new Config("vännäs", "vännäs");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("vännäs")).thenReturn(vannasConfig);
    final Config lyckseleConfig = new Config("lycksele", "lycksele");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("lycksele")).thenReturn(lyckseleConfig);
    final Config norrkopingConfig = new Config("norrköping", "norrköping");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("norrköping")).thenReturn(norrkopingConfig);
    final Config trollhattanConfig = new Config("trollhättan", "trollhättan");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("trollhättan")).thenReturn(trollhattanConfig);
    final Config helsingborgConfig = new Config("helsingborg", "helsingborg");
    when(SERVER_CONFIG_REPOSITORY.getConfigForServer("helsingborg")).thenReturn(helsingborgConfig);
    configMap = new HashMap<>();
    configMap.put("dalarna", dalarnaConfig);
    configMap.put("uppsala", uppsalaConfig);
    configMap.put("ängelholm", angelholmConfig);
    configMap.put("luleå", luleConfig);
    configMap.put("umeå", umeConfig);
    configMap.put("vännäs", vannasConfig);
    configMap.put("norrköping", norrkopingConfig);
    configMap.put("trollhättan", trollhattanConfig);
    configMap.put("helsingborg", helsingborgConfig);
    configMap.put("lycksele", lyckseleConfig);
    when(SERVER_CONFIG_REPOSITORY.getAllConfig()).thenReturn(configMap);
    repo = TestServerMain.getGymRepositoryForConfig(localeService, SERVER_CONFIG_REPOSITORY);
}
Also used : UserConfigRepository(pokeraidbot.infrastructure.jpa.config.UserConfigRepository) Config(pokeraidbot.infrastructure.jpa.config.Config) LocaleService(pokeraidbot.domain.config.LocaleService) Before(org.junit.Before)

Example 2 with LocaleService

use of pokeraidbot.domain.config.LocaleService in project pokeraidbot by magnusmickelsson.

the class CounterTextFileParserText method setUp.

@Before
public void setUp() throws Exception {
    UserConfigRepository userConfigRepository = Mockito.mock(UserConfigRepository.class);
    when(userConfigRepository.findOne(any(String.class))).thenReturn(null);
    localeService = new LocaleService("sv", userConfigRepository);
}
Also used : UserConfigRepository(pokeraidbot.infrastructure.jpa.config.UserConfigRepository) LocaleService(pokeraidbot.domain.config.LocaleService) Before(org.junit.Before)

Example 3 with LocaleService

use of pokeraidbot.domain.config.LocaleService in project pokeraidbot by magnusmickelsson.

the class UtilsTest method testPrintWeaknesses.

@Test
public void testPrintWeaknesses() throws Exception {
    PokemonRepository pokemonRepository = new PokemonRepository("/pokemons.csv", new LocaleService("sv", userConfigRepository));
    Pokemon pokemon = pokemonRepository.search("Tyranitar", null);
    assertThat(Utils.printWeaknesses(pokemon), is("Water, **Fighting**, Ground, Grass, Steel, Bug, Fairy"));
}
Also used : PokemonRepository(pokeraidbot.domain.pokemon.PokemonRepository) LocaleService(pokeraidbot.domain.config.LocaleService) Pokemon(pokeraidbot.domain.pokemon.Pokemon) Test(org.junit.Test)

Example 4 with LocaleService

use of pokeraidbot.domain.config.LocaleService in project pokeraidbot by magnusmickelsson.

the class UtilsTest method timeInRaidspan.

@Test
public void timeInRaidspan() throws Exception {
    User user = mock(User.class);
    when(user.getName()).thenReturn("User");
    LocalDateTime localDateTime = LocalDateTime.now();
    LocalDateTime same = localDateTime;
    LocalDateTime before = localDateTime.minusMinutes(1);
    LocalDateTime after = localDateTime.plusMinutes(1);
    LocalDateTime end = localDateTime.plusMinutes(Utils.RAID_DURATION_IN_MINUTES);
    LocalDateTime sameAsEnd = end;
    LocalDateTime beforeEnd = end.minusMinutes(1);
    LocalDateTime afterEnd = end.plusMinutes(1);
    final LocaleService localeService = mock(LocaleService.class);
    when(localeService.getMessageFor(any(), any(), any())).thenReturn("Mupp");
    Raid raid = new Raid(pokemonRepository.getByName("Tyranitar"), end, new Gym("Test", "id", "10", "10", null), localeService, "Test");
    checkWhetherAssertFails(user, same, localeService, raid, false);
    checkWhetherAssertFails(user, after, localeService, raid, false);
    checkWhetherAssertFails(user, before, localeService, raid, true);
    checkWhetherAssertFails(user, sameAsEnd, localeService, raid, false);
    checkWhetherAssertFails(user, afterEnd, localeService, raid, true);
    checkWhetherAssertFails(user, beforeEnd, localeService, raid, false);
}
Also used : LocalDateTime(java.time.LocalDateTime) User(net.dv8tion.jda.core.entities.User) LocaleService(pokeraidbot.domain.config.LocaleService) Gym(pokeraidbot.domain.gym.Gym) Raid(pokeraidbot.domain.raid.Raid) Test(org.junit.Test)

Example 5 with LocaleService

use of pokeraidbot.domain.config.LocaleService in project pokeraidbot by magnusmickelsson.

the class UtilsTest method before.

@BeforeClass
public static void before() {
    userConfigRepository = mock(UserConfigRepository.class);
    when(userConfigRepository.findOne(any(String.class))).thenReturn(null);
    localeService = new LocaleService("sv", userConfigRepository);
}
Also used : UserConfigRepository(pokeraidbot.infrastructure.jpa.config.UserConfigRepository) LocaleService(pokeraidbot.domain.config.LocaleService) BeforeClass(org.junit.BeforeClass)

Aggregations

LocaleService (pokeraidbot.domain.config.LocaleService)9 UserConfigRepository (pokeraidbot.infrastructure.jpa.config.UserConfigRepository)7 Before (org.junit.Before)5 PokemonRepository (pokeraidbot.domain.pokemon.PokemonRepository)3 Test (org.junit.Test)2 LocalDateTime (java.time.LocalDateTime)1 User (net.dv8tion.jda.core.entities.User)1 BeforeClass (org.junit.BeforeClass)1 Bean (org.springframework.context.annotation.Bean)1 Gym (pokeraidbot.domain.gym.Gym)1 Pokemon (pokeraidbot.domain.pokemon.Pokemon)1 Raid (pokeraidbot.domain.raid.Raid)1 Config (pokeraidbot.infrastructure.jpa.config.Config)1