Skip to content

Commit

Permalink
Merge pull request #88 from sriram-senthilkr/feature_branch
Browse files Browse the repository at this point in the history
Add Junit tests and added 2122 getInfo changes
  • Loading branch information
sriram-senthilkr authored Mar 29, 2023
2 parents 5adef38 + bbfa02c commit 87c62ae
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/penus/logic/utils/DetailsCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public static String getDetails(String module) {
return "This information is not available";
}
}

}
6 changes: 3 additions & 3 deletions src/main/java/seedu/penus/logic/utils/ModuleRetriever.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
25 changes: 21 additions & 4 deletions src/test/java/seedu/penus/logic/utils/DetailsCompilerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand All @@ -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);
}
}
67 changes: 66 additions & 1 deletion src/test/java/seedu/penus/logic/utils/ModuleRetrieverTest.java
Original file line number Diff line number Diff line change
@@ -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));
}

}

0 comments on commit 87c62ae

Please sign in to comment.