quest.setNpc(npc);
final BringListOfItemsQuestLogic logic = new BringListOfItemsQuestLogic(quest);
logic.addToWorld();
final Player player = PlayerTestHelper.createPlayer("player");
final Engine en = npc.getEngine();
en.step(player, "hi");
assertTrue(npc.isTalking());
assertEquals("first hi", quest.welcomeBeforeStartingQuest(), getReply(npc));
npc.put("text", "");
en.step(player, ConversationPhrases.QUEST_MESSAGES.get(0));
assertEquals("answer to quest", quest.respondToQuest(), getReply(npc));
en.step(player, ConversationPhrases.YES_MESSAGES.get(0));
assertEquals("answer to quests accepted", quest.respondToQuestAcception(), getReply(npc));
assertTrue(player.hasQuest(quest.getSlotName()));
assertFalse(npc.isTalking());
en.step(player, ConversationPhrases.GREETING_MESSAGES.get(0));
assertTrue(npc.isTalking());
en.step(player, quest.getTriggerPhraseToEnumerateMissingItems().get(0));
assertEquals("i have not brought anything yet it should be all needed items",
"#one, #two, and #three", getReply(npc));
StackableItem item = new StackableItem("one", "", "", null);
item.setQuantity(10);
item.setID(new ID(2, "testzone"));
player.getSlot("bag").add(item);
en.step(player, "yes");
assertEquals("item brought", quest.askForItemsAfterPlayerSaidHeHasItems(), getReply(npc));
en.step(player, "one");
assertEquals("item brought", quest.respondToItemBrought(), getReply(npc));
en.step(player, "one");
assertEquals("item brought", quest.respondToOfferOfNotMissingItem(), getReply(npc));
npc.remove("text");
assertEquals(ConversationStates.QUESTION_1, en.getCurrentState());
en.step(player, quest.getTriggerPhraseToEnumerateMissingItems().get(0));
final List<String> missing = new LinkedList<String>(quest.getNeededItems());
missing.remove("one");
assertEquals("two and three are missing", "#two and #three", getReply(npc));
en.step(player, "two");
assertEquals("item brought", quest.respondToOfferOfNotExistingItem("two"), getReply(npc));
item = new StackableItem("two", "", "", null);
item.setQuantity(10);
item.setID(new ID(2, "testzone"));
player.getSlot("bag").add(item);
item = new StackableItem("three", "", "", null);
item.setQuantity(10);
item.setID(new ID(2, "testzone"));
player.getSlot("bag").add(item);
en.step(player, "three");
assertEquals("item brought", quest.respondToItemBrought(), getReply(npc));
en.step(player, "two");
assertEquals("last item brought", quest.respondToLastItemBrought(), getReply(npc));
}