Search in sources :

Example 11 with Gym

use of pokeraidbot.domain.gym.Gym in project pokeraidbot by magnusmickelsson.

the class TestServerMain method getGymRepositoryForConfig.

public static GymRepository getGymRepositoryForConfig(LocaleService localeService, ServerConfigRepository serverConfigRepository) {
    Map<String, Set<Gym>> gymsPerRegion = new HashMap<>();
    final Map<String, Config> configMap = serverConfigRepository.getAllConfig();
    System.out.println("Config has following servers: " + configMap.keySet());
    for (String server : configMap.keySet()) {
        final Config config = serverConfigRepository.getConfigForServer(server);
        final String region = config.getRegion();
        if (!gymsPerRegion.containsKey(region)) {
            final Set<Gym> gymsInRegion = new CSVGymDataReader("/gyms_" + region + ".csv").readAll();
            gymsPerRegion.put(region, gymsInRegion);
            System.out.println("Loaded " + gymsInRegion.size() + " gyms for server " + server + ".");
        }
    }
    return new GymRepository(gymsPerRegion, localeService);
}
Also used : Set(java.util.Set) GymRepository(pokeraidbot.domain.gym.GymRepository) HashMap(java.util.HashMap) Config(pokeraidbot.infrastructure.jpa.config.Config) Gym(pokeraidbot.domain.gym.Gym) CSVGymDataReader(pokeraidbot.infrastructure.CSVGymDataReader)

Example 12 with Gym

use of pokeraidbot.domain.gym.Gym in project pokeraidbot by magnusmickelsson.

the class GymRepositoryTest method noDuplicatesInDataFiles.

@Test
public void noDuplicatesInDataFiles() {
    Map<String, Set<Gym>> gymData = repo.getAllGymData();
    for (String region : gymData.keySet()) {
        Set<Gym> gyms = gymData.get(region);
        for (Gym gym : gyms) {
            final Gym gymFromRepo = repo.findByName(gym.getName(), region);
            assertThat("Seems we have a duplicate for gymname: " + gym.getName() + " \n" + gymFromRepo.toStringDetails() + " != " + gym.toStringDetails(), gymFromRepo, is(gym));
        }
    }
}
Also used : Set(java.util.Set) Gym(pokeraidbot.domain.gym.Gym) Test(org.junit.Test)

Example 13 with Gym

use of pokeraidbot.domain.gym.Gym in project pokeraidbot by magnusmickelsson.

the class GymRepositoryTest method malakIsExGym.

@Test
public void malakIsExGym() throws Exception {
    final Gym gym = repo.findByName("Malak", "vännäs");
    assertThat(gym.isInArea("Vännäs"), is(true));
    assertThat(gym.isExGym(), is(true));
}
Also used : Gym(pokeraidbot.domain.gym.Gym) Test(org.junit.Test)

Example 14 with Gym

use of pokeraidbot.domain.gym.Gym in project pokeraidbot by magnusmickelsson.

the class GymRepositoryTest method assertAllExGymsInRegion.

private void assertAllExGymsInRegion(String region) {
    Set<String> exGymNamesForRegion;
    final String fileName = "/gyms_" + region.toLowerCase() + ".csv.ex.txt";
    final InputStream inputStreamEx = GymRepositoryTest.class.getResourceAsStream(fileName);
    exGymNamesForRegion = CSVGymDataReader.readExGymListIfExists(inputStreamEx, fileName);
    for (String gymName : exGymNamesForRegion) {
        final Gym gym = repo.findByName(gymName, region);
        assertThat(gym != null, is(true));
        assertThat(gym.getName(), is(gymName));
    }
}
Also used : InputStream(java.io.InputStream) Gym(pokeraidbot.domain.gym.Gym)

Example 15 with Gym

use of pokeraidbot.domain.gym.Gym in project pokeraidbot by magnusmickelsson.

the class GymRepositoryTest method feather360IsExGym.

@Test
public void feather360IsExGym() throws Exception {
    final Gym feather360 = repo.findByName("Feather Sculpture 360", "uppsala");
    assertThat(feather360.isInArea("Uppsala"), is(true));
    assertThat(feather360.isExGym(), is(true));
}
Also used : Gym(pokeraidbot.domain.gym.Gym) Test(org.junit.Test)

Aggregations

Gym (pokeraidbot.domain.gym.Gym)37 User (net.dv8tion.jda.core.entities.User)18 Raid (pokeraidbot.domain.raid.Raid)16 LocalDateTime (java.time.LocalDateTime)15 LocalTime (java.time.LocalTime)13 Test (org.junit.Test)12 UserMessedUpException (pokeraidbot.domain.errors.UserMessedUpException)12 Pokemon (pokeraidbot.domain.pokemon.Pokemon)11 Locale (java.util.Locale)8 Config (pokeraidbot.infrastructure.jpa.config.Config)7 SignUp (pokeraidbot.domain.raid.signup.SignUp)6 RaidGroup (pokeraidbot.infrastructure.jpa.raid.RaidGroup)6 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)5 Guild (net.dv8tion.jda.core.entities.Guild)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)4 PokemonRaidInfo (pokeraidbot.domain.pokemon.PokemonRaidInfo)3 InputStream (java.io.InputStream)2 LocalDate (java.time.LocalDate)2 Set (java.util.Set)2