From 9166dc2d186fd676e5b2d91803d41e283249d418 Mon Sep 17 00:00:00 2001 From: Tanja Herche Date: Fri, 3 Feb 2023 20:46:39 +0100 Subject: [PATCH] Unittest: integrate TravelEngine and Player --- .../java/org/bitbiome/commands/MapCommand.java | 18 ++++++++---------- .../org/bitbiome/commands/MapCommandTest.java | 8 ++++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/bitbiome/commands/MapCommand.java b/src/main/java/org/bitbiome/commands/MapCommand.java index 3b1620c..44cdd6a 100644 --- a/src/main/java/org/bitbiome/commands/MapCommand.java +++ b/src/main/java/org/bitbiome/commands/MapCommand.java @@ -1,23 +1,21 @@ package org.bitbiome.commands; - import org.bitbiome.classes.TravelEngine; - +import org.json.JSONArray; import java.util.Scanner; public class MapCommand implements CommandAPI{ - @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { - System.out.println(getMapMessage()); + System.out.println(getMapMessage(travelEngine)); } - public static String getMapMessage() { + public static String getMapMessage(TravelEngine travelEngine) { StringBuilder outputMessage = new StringBuilder(); - outputMessage - .append("Map:\n") - .append("Wueste Gruendland Winterland\n\n") - .append("Strand Wald Berge\n\n"); + JSONArray locations = travelEngine.getLocationList(); + outputMessage + .append("Map:\n") + .append("Wueste Gruenland Winterland\n\n") + .append("Strand Wald Berge\n\n"); return outputMessage.toString(); } - } diff --git a/src/test/java/org/bitbiome/commands/MapCommandTest.java b/src/test/java/org/bitbiome/commands/MapCommandTest.java index def2566..10f2407 100644 --- a/src/test/java/org/bitbiome/commands/MapCommandTest.java +++ b/src/test/java/org/bitbiome/commands/MapCommandTest.java @@ -1,5 +1,7 @@ package org.bitbiome.commands; +import org.bitbiome.classes.TravelEngine; +import org.bitbiome.entities.Player; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -7,11 +9,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class MapCommandTest { @Test public void testMapCommand() { - String mapMessage = MapCommand.getMapMessage(); + Player Test = new Player("name"); + TravelEngine outputtest = new TravelEngine(Test); + String mapMessage = MapCommand.getMapMessage(outputtest); StringBuilder outputMessage = new StringBuilder(); outputMessage .append("Map:\n") - .append("Wueste Gruendland Winterland\n\n") + .append("Wueste Gruenland Winterland\n\n") .append("Strand Wald Berge\n\n"); assertEquals(outputMessage.toString(), mapMessage); }