diff --git a/src/main/java/seedu/penus/logic/utils/DetailsCompiler.java b/src/main/java/seedu/penus/logic/utils/DetailsCompiler.java index 0e9859f841..87ba943ae4 100644 --- a/src/main/java/seedu/penus/logic/utils/DetailsCompiler.java +++ b/src/main/java/seedu/penus/logic/utils/DetailsCompiler.java @@ -22,4 +22,5 @@ public static String getDetails(String module) { return "This information is not available"; } } + } diff --git a/src/main/java/seedu/penus/logic/utils/ModuleRetriever.java b/src/main/java/seedu/penus/logic/utils/ModuleRetriever.java index e0aa483048..4152e4ed44 100644 --- a/src/main/java/seedu/penus/logic/utils/ModuleRetriever.java +++ b/src/main/java/seedu/penus/logic/utils/ModuleRetriever.java @@ -145,7 +145,7 @@ public static String getModuleCredit2223(String module) { public static String getTitle2122(String module) { try { getData2122(module); - return (String) moduleInfo2223.get("title"); + return (String) moduleInfo2122.get("title"); } catch (InvalidModuleAPIException e) { //e.printStackTrace(); return null; @@ -155,7 +155,7 @@ public static String getTitle2122(String module) { public static String getModuleCredit2122(String module) { try { getData2122(module); - return (String) moduleInfo2223.get("moduleCredit"); + return (String) moduleInfo2122.get("moduleCredit"); } catch (InvalidModuleAPIException e) { //e.printStackTrace(); return null; @@ -168,7 +168,7 @@ public static Boolean getSUstatus(String module) { JSONObject attributes = (JSONObject) moduleInfo2223.get("attributes"); Boolean suStatus = (Boolean) attributes.get("su"); - return suStatus == null; + return suStatus; } catch (InvalidModuleAPIException e) { //e.printStackTrace(); return null; diff --git a/src/test/java/seedu/penus/logic/utils/DetailsCompilerTest.java b/src/test/java/seedu/penus/logic/utils/DetailsCompilerTest.java index 5b827f9a27..b2181cc8c9 100644 --- a/src/test/java/seedu/penus/logic/utils/DetailsCompilerTest.java +++ b/src/test/java/seedu/penus/logic/utils/DetailsCompilerTest.java @@ -9,9 +9,9 @@ class DetailsCompilerTest { private DetailsCompiler details; @Test void getDetailsForCS2113() { - String moduleCode = "CS2113"; - String cS2113Details = details.getDetails(moduleCode); - String expectedOutput = "Software Engineering & Object-Oriented Programming\n\tThis module introduces the " + + String ModuleCode = "CS2113"; + String ActualOutput = details.getDetails(ModuleCode); + String ExpectedOutput = "Software Engineering & Object-Oriented Programming\n\tThis module introduces the " + "necessary skills for systematic and rigorous development of software systems. It covers " + "requirements, design, implementation, quality assurance, and project management aspects of " + "small-to-medium size multi-person software projects. The module uses the Object Oriented Programming" + @@ -20,6 +20,23 @@ void getDetailsForCS2113() { "covered.\n\tPre-Requisites: CS2040C or ((CS2030 or its equivalent) and CS2040/S)\n\tMCs: 4\n\tModule" + " can be SU-ed."; - assertEquals(expectedOutput, cS2113Details); + assertEquals(ExpectedOutput, ActualOutput); + } + @Test + void getDetailsForInvalidModule() { + String ModuleCode = "INVALID MODULE"; + String ActualOutput = details.getDetails(ModuleCode); + String ExpectedOutput = "This information is not available"; + + assertEquals(ExpectedOutput, ActualOutput); + } + + @Test + void getDetailsForNull() { + String ModuleCode = null; + String ActualOutput = details.getDetails(ModuleCode); + String ExpectedOutput = "This information is not available"; + + assertEquals(ExpectedOutput, ActualOutput); } } diff --git a/src/test/java/seedu/penus/logic/utils/ModuleRetrieverTest.java b/src/test/java/seedu/penus/logic/utils/ModuleRetrieverTest.java index 40feba75ca..9ef31ecfa3 100644 --- a/src/test/java/seedu/penus/logic/utils/ModuleRetrieverTest.java +++ b/src/test/java/seedu/penus/logic/utils/ModuleRetrieverTest.java @@ -1,5 +1,70 @@ package seedu.penus.logic.utils; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; -class ModuleRetrieverTest { +public class ModuleRetrieverTest { + + @Test + void testGetDescription() { + String module = "CS2103T"; + String expectedDescription = "This module introduces the necessary conceptual and analytical tools for " + + "systematic and rigorous development of software systems. It covers four main areas of software development, " + + "namely object-oriented system analysis, object-oriented system modelling and design, implementation, and testing, " + + "with emphasis on system modelling and design and implementation of software modules that work cooperatively to " + + "fulfill the requirements of the system. Tools and techniques for software development, such as Unified Modelling Language (UML)," + + " program specification, and testing methods, will be taught. Major software engineering issues such as modularisation criteria, " + + "program correctness, and software quality will also be covered."; + + assertEquals(expectedDescription, ModuleRetriever.getDescription(module)); + } + + @Test + void testGetPrerequisite() { + String module = "CS2103T"; + String expectedPrerequisite = "For SoC students only. (CS1020 or its equivalent) or CS2020 or ((CS2030 or its equivalent) and (CS2040 or its equivalent))"; + + assertEquals(expectedPrerequisite, ModuleRetriever.getPrerequisite(module)); + } + + @Test + void testGetTitle2223() { + String module = "CS2103T"; + String expectedTitle = "Software Engineering"; + + assertEquals(expectedTitle, ModuleRetriever.getTitle2223(module)); + } + + @Test + void testGetModuleCredit2223() { + String module = "CS2103T"; + String expectedModuleCredit = "4"; + + assertEquals(expectedModuleCredit, ModuleRetriever.getModuleCredit2223(module)); + } + + @Test + void testGetTitle2122() { + String module = "CS2103T"; + String expectedTitle = "Software Engineering"; + + assertEquals(expectedTitle, ModuleRetriever.getTitle2122(module)); + } + + @Test + void testGetModuleCredit2122() { + String module = "CS2103T"; + String expectedModuleCredit = "4"; + + assertEquals(expectedModuleCredit, ModuleRetriever.getModuleCredit2122(module)); + } + + @Test + void testGetSUstatus() { + String module = "PF1101"; + Boolean expectedSUstatus = true; + + assertEquals(expectedSUstatus, ModuleRetriever.getSUstatus(module)); + } } +