From e8842e54cd906f6c67fdc395bd8b99ab3ff18bb3 Mon Sep 17 00:00:00 2001 From: Juliakn66 <117075450+Juliakn66@users.noreply.github.com> Date: Sat, 4 Feb 2023 14:00:05 +0100 Subject: [PATCH] unittest: added testGetLocationObject ro LookaroundCommandTest --- .../commands/LookaroundCommandTest.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/test/java/org/bitbiome/commands/LookaroundCommandTest.java diff --git a/src/test/java/org/bitbiome/commands/LookaroundCommandTest.java b/src/test/java/org/bitbiome/commands/LookaroundCommandTest.java new file mode 100644 index 0000000..24e7ba4 --- /dev/null +++ b/src/test/java/org/bitbiome/commands/LookaroundCommandTest.java @@ -0,0 +1,40 @@ +package org.bitbiome.commands; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + + + +public class LookaroundCommandTest { + private JSONArray locations; + + @Test + public void testGetLocationObject(){ + LookaroundCommand command = new LookaroundCommand(); + locations = new JSONArray(); + JSONObject location1 = new JSONObject(); + location1.put("name", "Wald"); + location1.put("description", "Es gibt Bäume und Sträucher"); + JSONObject location2 = new JSONObject(); + location2.put("name", "Strand"); + location2.put("description", "Weiter, weißer Sandstrand am Meer"); + locations.put(location1); + locations.put(location2); + + JSONObject result = command.getLocationObject("Wald", locations); + assertEquals("Wald", result.getString("name")); + assertEquals("Es gibt Bäume und Sträucher", result.getString("description")); + + result = command.getLocationObject("Strand", locations); + assertEquals("Strand", result.getString("name")); + assertEquals("Weiter, weißer Sandstrand am Meer", result.getString("description")); + + result = command.getLocationObject("not existing location", locations); + assertEquals("Wald", result.getString("name")); + assertEquals("Es gibt Bäume und Sträucher", result.getString("description")); + } + +}