@Test public void refresh() throws IOException { Files.copy( SpeciesPropertiesTraderTest.class.getResourceAsStream("species-tyrannosaurus-rex.json"), location, REPLACE_EXISTING); subject.refresh(); assertThat(subject.getAll(), hasSize(1)); assertThat(subject.getAll().iterator().next().referenceName(), is("tyrannosaurus rex")); }
@PostConstruct public String refresh() throws IOException { try { LOGGER.info("Reading species properties..."); ImmutableSortedMap<String, SpeciesProperties> newMap = buildMap(); MapDifference<String, SpeciesProperties> diff = Maps.difference(nameToSpecies, newMap); nameToSpecies = newMap; LOGGER.info("Retrieved {} species properties", nameToSpecies.size()); return describeMapDifference(diff); } catch (IOException e) { LOGGER.error("Error reading species properties"); throw e; } }
SpeciesPropertiesTrader { @PostConstruct public String refresh() throws IOException { try { LOGGER.info("Reading species properties..."); ImmutableSortedMap<String, SpeciesProperties> newMap = buildMap(); MapDifference<String, SpeciesProperties> diff = Maps.difference(nameToSpecies, newMap); nameToSpecies = newMap; LOGGER.info("Retrieved {} species properties", nameToSpecies.size()); return describeMapDifference(diff); } catch (IOException e) { LOGGER.error("Error reading species properties"); throw e; } } }
SpeciesPropertiesTrader { @PostConstruct public String refresh() throws IOException { try { LOGGER.info("Reading species properties..."); ImmutableSortedMap<String, SpeciesProperties> newMap = buildMap(); MapDifference<String, SpeciesProperties> diff = Maps.difference(nameToSpecies, newMap); nameToSpecies = newMap; LOGGER.info("Retrieved {} species properties", nameToSpecies.size()); return describeMapDifference(diff); } catch (IOException e) { LOGGER.error("Error reading species properties"); throw e; } }  }
SpeciesPropertiesTrader { @PostConstruct public String refresh() throws IOException { try { LOGGER.info("Reading species properties..."); ImmutableSortedMap<String, SpeciesProperties> newMap = buildMap(); MapDifference<String, SpeciesProperties> diff = Maps.difference(nameToSpecies, newMap); nameToSpecies = newMap; LOGGER.info("Retrieved {} species properties", nameToSpecies.size()); return describeMapDifference(diff); } catch (IOException e) { LOGGER.error("Error reading species properties"); throw e; } }  @Inject void setSpeciesPropertiesDao(SpeciesPropertiesDao speciesPropertiesDao); @PostConstruct String refresh(); SpeciesProperties get(String speciesName); Collection<SpeciesProperties> getAll(); }
SpeciesPropertiesTrader { @PostConstruct public String refresh() throws IOException { try { LOGGER.info("Reading species properties..."); ImmutableSortedMap<String, SpeciesProperties> newMap = buildMap(); MapDifference<String, SpeciesProperties> diff = Maps.difference(nameToSpecies, newMap); nameToSpecies = newMap; LOGGER.info("Retrieved {} species properties", nameToSpecies.size()); return describeMapDifference(diff); } catch (IOException e) { LOGGER.error("Error reading species properties"); throw e; } }  @Inject void setSpeciesPropertiesDao(SpeciesPropertiesDao speciesPropertiesDao); @PostConstruct String refresh(); SpeciesProperties get(String speciesName); Collection<SpeciesProperties> getAll();  }