@Test public void testRetrieveAll() { final NPCProperties[] npcProperties; try { npcProperties = dao.retrieveAll(); } catch (final DAOException e) { fail("Loading of npcs failed with message " + e.getMessage()); return; } final NPCProperties snake = npcProperties[COMMON_NPC_INDEX]; assertThat(snake, instanceOf(CreatureNPCProperties.class)); assertEquals(NPCType.COMMON, snake.getType()); final NPCProperties dragon = npcProperties[DRAGON_NPC_INDEX]; assertThat(dragon, instanceOf(CreatureNPCProperties.class)); assertEquals(NPCType.DRAGON, dragon.getType()); final NPCProperties trainer = npcProperties[TRAINER_NPC_INDEX]; assertThat(trainer, instanceOf(TrainerNPCProperties.class)); assertEquals(NPCType.TRAINER, trainer.getType()); final NPCProperties governor = npcProperties[GOVERNOR_NPC_INDEX]; assertThat(governor, instanceOf(GovernorNPCProperties.class)); assertEquals(NPCType.GOVERNOR, governor.getType()); final NPCProperties royalGuard = npcProperties[ROYAL_GUARD_NPC_INDEX]; assertThat(royalGuard, instanceOf(GuardNPCProperties.class)); assertEquals(NPCType.ROYAL_GUARD, royalGuard.getType()); final NPCProperties chaosGuard = npcProperties[CHAOS_GUARD_NPC_INDEX]; assertThat(chaosGuard, instanceOf(GuardNPCProperties.class)); assertEquals(NPCType.CHAOS_GUARD, chaosGuard.getType()); final NPCProperties newbieResucitator = npcProperties[NEWBIE_RESUCITATOR_NPC_INDEX]; assertThat(newbieResucitator, instanceOf(NPCProperties.class)); assertEquals(NPCType.NEWBIE_RESUCITATOR, newbieResucitator.getType()); final NPCProperties resucitator = npcProperties[RESUCITATOR_NPC_INDEX]; assertThat(resucitator, instanceOf(NPCProperties.class)); assertEquals(NPCType.RESUCITATOR, resucitator.getType()); final NPCProperties gambler = npcProperties[GAMBLER_NPC_INDEX]; assertThat(gambler, instanceOf(NPCProperties.class)); assertEquals(NPCType.GAMBLER, gambler.getType()); final NPCProperties banker = npcProperties[BANKER_NPC_INDEX]; assertThat(banker, instanceOf(NPCProperties.class)); assertEquals(NPCType.BANKER, banker.getType()); final NPCProperties noble = npcProperties[NOBLE_NPC_INDEX]; assertThat(noble, instanceOf(NobleNPCProperties.class)); assertEquals(NPCType.NOBLE, noble.getType()); }
@Override public NPCProperties[] retrieveAll() throws DAOException { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(npcsFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { logger.error("NPC loading failed!", e); throw new DAOException(e); } int totalNpcs = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_NPCS_KEY)); NPCProperties[] npcs = new NPCProperties[totalNpcs]; for (int i = 1; i < totalNpcs; i++) { npcs[i - 1] = loadNpc(i, iniFile); } return npcs; }
NPCPropertiesDAOIni implements NPCCharacterPropertiesDAO { @Override public NPCProperties[] retrieveAll() throws DAOException { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(npcsFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { logger.error("NPC loading failed!", e); throw new DAOException(e); } int totalNpcs = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_NPCS_KEY)); NPCProperties[] npcs = new NPCProperties[totalNpcs]; for (int i = 1; i < totalNpcs; i++) { npcs[i - 1] = loadNpc(i, iniFile); } return npcs; } }
NPCPropertiesDAOIni implements NPCCharacterPropertiesDAO { @Override public NPCProperties[] retrieveAll() throws DAOException { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(npcsFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { logger.error("NPC loading failed!", e); throw new DAOException(e); } int totalNpcs = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_NPCS_KEY)); NPCProperties[] npcs = new NPCProperties[totalNpcs]; for (int i = 1; i < totalNpcs; i++) { npcs[i - 1] = loadNpc(i, iniFile); } return npcs; } @Inject  NPCPropertiesDAOIni(@Named("npcsFilePath") String npcsFilePath,
			WorldObjectPropertiesDAO worldObjectPropertiesDAO, WorldObjectFactory worldObjectFactory); }
NPCPropertiesDAOIni implements NPCCharacterPropertiesDAO { @Override public NPCProperties[] retrieveAll() throws DAOException { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(npcsFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { logger.error("NPC loading failed!", e); throw new DAOException(e); } int totalNpcs = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_NPCS_KEY)); NPCProperties[] npcs = new NPCProperties[totalNpcs]; for (int i = 1; i < totalNpcs; i++) { npcs[i - 1] = loadNpc(i, iniFile); } return npcs; } @Inject  NPCPropertiesDAOIni(@Named("npcsFilePath") String npcsFilePath,
			WorldObjectPropertiesDAO worldObjectPropertiesDAO, WorldObjectFactory worldObjectFactory); @Override NPCProperties[] retrieveAll(); }
NPCPropertiesDAOIni implements NPCCharacterPropertiesDAO { @Override public NPCProperties[] retrieveAll() throws DAOException { Ini iniFile; try { Reader reader = new BufferedReader(new FileReader(npcsFilePath)); iniFile = new Ini(reader); reader.close(); } catch (Exception e) { logger.error("NPC loading failed!", e); throw new DAOException(e); } int totalNpcs = Integer.parseInt(iniFile.get(INIT_HEADER, NUM_NPCS_KEY)); NPCProperties[] npcs = new NPCProperties[totalNpcs]; for (int i = 1; i < totalNpcs; i++) { npcs[i - 1] = loadNpc(i, iniFile); } return npcs; } @Inject  NPCPropertiesDAOIni(@Named("npcsFilePath") String npcsFilePath,
			WorldObjectPropertiesDAO worldObjectPropertiesDAO, WorldObjectFactory worldObjectFactory); @Override NPCProperties[] retrieveAll();  }