diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 00000000..8268168f
Binary files /dev/null and b/.DS_Store differ
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..26d33521
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/4156-Miniproject-2024-Students-Java.iml b/.idea/4156-Miniproject-2024-Students-Java.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/.idea/4156-Miniproject-2024-Students-Java.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 00000000..a55e7a17
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 00000000..64129d26
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 00000000..28c13ebd
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 00000000..712ab9d9
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_4_14.xml b/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_4_14.xml
new file mode 100644
index 00000000..ac6986ac
--- /dev/null
+++ b/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_4_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__ch_qos_logback_logback_core_1_4_14.xml b/.idea/libraries/Maven__ch_qos_logback_logback_core_1_4_14.xml
new file mode 100644
index 00000000..7a386238
--- /dev/null
+++ b/.idea/libraries/Maven__ch_qos_logback_logback_core_1_4_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_15_3.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_15_3.xml
new file mode 100644
index 00000000..b194d9db
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_15_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_15_3.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_15_3.xml
new file mode 100644
index 00000000..b1af4320
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_15_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_15_3.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_15_3.xml
new file mode 100644
index 00000000..86cd6587
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_15_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_15_3.xml b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_15_3.xml
new file mode 100644
index 00000000..bffd2900
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_15_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_15_3.xml b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_15_3.xml
new file mode 100644
index 00000000..50fc0698
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_15_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_15_3.xml b/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_15_3.xml
new file mode 100644
index 00000000..65bce52d
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_15_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_8_0.xml b/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_8_0.xml
new file mode 100644
index 00000000..2cb631f9
--- /dev/null
+++ b/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_8_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml b/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml
new file mode 100644
index 00000000..b8581a6f
--- /dev/null
+++ b/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_micrometer_micrometer_commons_1_12_2.xml b/.idea/libraries/Maven__io_micrometer_micrometer_commons_1_12_2.xml
new file mode 100644
index 00000000..cf8ca3f4
--- /dev/null
+++ b/.idea/libraries/Maven__io_micrometer_micrometer_commons_1_12_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_micrometer_micrometer_observation_1_12_2.xml b/.idea/libraries/Maven__io_micrometer_micrometer_observation_1_12_2.xml
new file mode 100644
index 00000000..54e7a97b
--- /dev/null
+++ b/.idea/libraries/Maven__io_micrometer_micrometer_observation_1_12_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__jakarta_activation_jakarta_activation_api_2_1_2.xml b/.idea/libraries/Maven__jakarta_activation_jakarta_activation_api_2_1_2.xml
new file mode 100644
index 00000000..58afa68a
--- /dev/null
+++ b/.idea/libraries/Maven__jakarta_activation_jakarta_activation_api_2_1_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__jakarta_annotation_jakarta_annotation_api_2_1_1.xml b/.idea/libraries/Maven__jakarta_annotation_jakarta_annotation_api_2_1_1.xml
new file mode 100644
index 00000000..3f660ae4
--- /dev/null
+++ b/.idea/libraries/Maven__jakarta_annotation_jakarta_annotation_api_2_1_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__jakarta_xml_bind_jakarta_xml_bind_api_4_0_1.xml b/.idea/libraries/Maven__jakarta_xml_bind_jakarta_xml_bind_api_4_0_1.xml
new file mode 100644
index 00000000..75d958a3
--- /dev/null
+++ b/.idea/libraries/Maven__jakarta_xml_bind_jakarta_xml_bind_api_4_0_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_14_11.xml b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_14_11.xml
new file mode 100644
index 00000000..a138e1b4
--- /dev/null
+++ b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_14_11.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_14_11.xml b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_14_11.xml
new file mode 100644
index 00000000..6ee27aeb
--- /dev/null
+++ b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_14_11.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_minidev_accessors_smart_2_5_0.xml b/.idea/libraries/Maven__net_minidev_accessors_smart_2_5_0.xml
new file mode 100644
index 00000000..67b8687f
--- /dev/null
+++ b/.idea/libraries/Maven__net_minidev_accessors_smart_2_5_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_minidev_json_smart_2_5_0.xml b/.idea/libraries/Maven__net_minidev_json_smart_2_5_0.xml
new file mode 100644
index 00000000..32246c40
--- /dev/null
+++ b/.idea/libraries/Maven__net_minidev_json_smart_2_5_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_client5_httpclient5_5_2_3.xml b/.idea/libraries/Maven__org_apache_httpcomponents_client5_httpclient5_5_2_3.xml
new file mode 100644
index 00000000..6255d88f
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_httpcomponents_client5_httpclient5_5_2_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_core5_httpcore5_5_2_4.xml b/.idea/libraries/Maven__org_apache_httpcomponents_core5_httpcore5_5_2_4.xml
new file mode 100644
index 00000000..c154d6c0
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_httpcomponents_core5_httpcore5_5_2_4.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_httpcomponents_core5_httpcore5_h2_5_2_4.xml b/.idea/libraries/Maven__org_apache_httpcomponents_core5_httpcore5_h2_5_2_4.xml
new file mode 100644
index 00000000..685c0599
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_httpcomponents_core5_httpcore5_h2_5_2_4.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_21_1.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_21_1.xml
new file mode 100644
index 00000000..ba17f0e8
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_21_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_21_1.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_21_1.xml
new file mode 100644
index 00000000..30065dd5
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_21_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_10_1_18.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_10_1_18.xml
new file mode 100644
index 00000000..25acdc68
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_10_1_18.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_10_1_18.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_10_1_18.xml
new file mode 100644
index 00000000..b3b3c18e
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_10_1_18.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_10_1_18.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_10_1_18.xml
new file mode 100644
index 00000000..ff7564ad
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_10_1_18.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_2.xml b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_2.xml
new file mode 100644
index 00000000..6ac1c42c
--- /dev/null
+++ b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_assertj_assertj_core_3_24_2.xml b/.idea/libraries/Maven__org_assertj_assertj_core_3_24_2.xml
new file mode 100644
index 00000000..8fa95240
--- /dev/null
+++ b/.idea/libraries/Maven__org_assertj_assertj_core_3_24_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_awaitility_awaitility_4_2_0.xml b/.idea/libraries/Maven__org_awaitility_awaitility_4_2_0.xml
new file mode 100644
index 00000000..cd03dd97
--- /dev/null
+++ b/.idea/libraries/Maven__org_awaitility_awaitility_4_2_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_2_2.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_2_2.xml
new file mode 100644
index 00000000..6b5496ff
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_10_1.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_10_1.xml
new file mode 100644
index 00000000..6e86eeb2
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_10_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_10_1.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_10_1.xml
new file mode 100644
index 00000000..31355875
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_10_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_10_1.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_10_1.xml
new file mode 100644
index 00000000..68b79036
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_10_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_10_1.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_10_1.xml
new file mode 100644
index 00000000..dad8df0c
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_10_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_10_1.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_10_1.xml
new file mode 100644
index 00000000..a0f728d8
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_10_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_10_1.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_10_1.xml
new file mode 100644
index 00000000..90b85094
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_10_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mockito_mockito_core_5_7_0.xml b/.idea/libraries/Maven__org_mockito_mockito_core_5_7_0.xml
new file mode 100644
index 00000000..99bc6244
--- /dev/null
+++ b/.idea/libraries/Maven__org_mockito_mockito_core_5_7_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mockito_mockito_junit_jupiter_5_7_0.xml b/.idea/libraries/Maven__org_mockito_mockito_junit_jupiter_5_7_0.xml
new file mode 100644
index 00000000..2b6be62f
--- /dev/null
+++ b/.idea/libraries/Maven__org_mockito_mockito_junit_jupiter_5_7_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_objenesis_objenesis_3_3.xml b/.idea/libraries/Maven__org_objenesis_objenesis_3_3.xml
new file mode 100644
index 00000000..3a3576c7
--- /dev/null
+++ b/.idea/libraries/Maven__org_objenesis_objenesis_3_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_opentest4j_opentest4j_1_3_0.xml b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_3_0.xml
new file mode 100644
index 00000000..87e7ec88
--- /dev/null
+++ b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_3_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_ow2_asm_asm_9_3.xml b/.idea/libraries/Maven__org_ow2_asm_asm_9_3.xml
new file mode 100644
index 00000000..ce5a26c8
--- /dev/null
+++ b/.idea/libraries/Maven__org_ow2_asm_asm_9_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_1.xml b/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_1.xml
new file mode 100644
index 00000000..56582d63
--- /dev/null
+++ b/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_2_0_11.xml b/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_2_0_11.xml
new file mode 100644
index 00000000..01d6d92a
--- /dev/null
+++ b/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_2_0_11.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_slf4j_slf4j_api_2_0_11.xml b/.idea/libraries/Maven__org_slf4j_slf4j_api_2_0_11.xml
new file mode 100644
index 00000000..893675a9
--- /dev/null
+++ b/.idea/libraries/Maven__org_slf4j_slf4j_api_2_0_11.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_3_2_2.xml
new file mode 100644
index 00000000..b90568e3
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_3_2_2.xml
new file mode 100644
index 00000000..28aabc86
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_3_2_2.xml
new file mode 100644
index 00000000..a8563e6d
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_3_2_2.xml
new file mode 100644
index 00000000..8a26ba41
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_3_2_2.xml
new file mode 100644
index 00000000..4b4c5f7c
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_3_2_2.xml
new file mode 100644
index 00000000..f0c1fc1b
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_3_2_2.xml
new file mode 100644
index 00000000..df7e9064
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_3_2_2.xml
new file mode 100644
index 00000000..d8014360
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_3_2_2.xml
new file mode 100644
index 00000000..4da32551
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_3_2_2.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_3_2_2.xml
new file mode 100644
index 00000000..e5d2ffaa
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_3_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_aop_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_aop_6_1_3.xml
new file mode 100644
index 00000000..d0f8376e
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_aop_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_beans_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_beans_6_1_3.xml
new file mode 100644
index 00000000..ad680b1a
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_beans_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_context_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_context_6_1_3.xml
new file mode 100644
index 00000000..d1f8c22d
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_context_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_core_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_core_6_1_3.xml
new file mode 100644
index 00000000..95226e92
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_core_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_expression_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_expression_6_1_3.xml
new file mode 100644
index 00000000..822f494d
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_expression_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_jcl_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_jcl_6_1_3.xml
new file mode 100644
index 00000000..526a8cac
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_jcl_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_test_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_test_6_1_3.xml
new file mode 100644
index 00000000..442bce45
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_test_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_web_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_web_6_1_3.xml
new file mode 100644
index 00000000..d30a176f
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_web_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_webmvc_6_1_3.xml b/.idea/libraries/Maven__org_springframework_spring_webmvc_6_1_3.xml
new file mode 100644
index 00000000..6d24fc70
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_webmvc_6_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_9_1.xml b/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_9_1.xml
new file mode 100644
index 00000000..e2f6d14d
--- /dev/null
+++ b/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_9_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_yaml_snakeyaml_2_2.xml b/.idea/libraries/Maven__org_yaml_snakeyaml_2_2.xml
new file mode 100644
index 00000000..998e133e
--- /dev/null
+++ b/.idea/libraries/Maven__org_yaml_snakeyaml_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..a132076d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..4e6a9c45
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 00000000..2b63946d
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/IndividualProject/.DS_Store b/IndividualProject/.DS_Store
new file mode 100644
index 00000000..641410bb
Binary files /dev/null and b/IndividualProject/.DS_Store differ
diff --git a/IndividualProject/bugs.txt b/IndividualProject/bugs.txt
new file mode 100644
index 00000000..6254c60a
--- /dev/null
+++ b/IndividualProject/bugs.txt
@@ -0,0 +1,10 @@
+1. Return false from dropStudent
+2. Return false from enrollStudent
+3. getMajorCtFromDept returns "There are: " + -departmentMapping.get(deptCode) -numberOfCourse
+4. In getMajorCtFromDept returns HttpStatus.FORBIDDEN if the dept doesn't exist
+5. In retrieveDept returns HttpStatus.NOT_FOUND when course exists
+6. In retrieveCourse returns HttpStatus.NOT_FOUND when course exists
+7. getNumberOfMajors returns -this.numberOfMajors;
+8. getDepartmentChair returns "this.departmentChair"
+9. Department.toString returns "result.toString()"
+10. isCourseFull returns enrollmentCapacity > enrolledStudentCount
diff --git a/IndividualProject/citations.txt b/IndividualProject/citations.txt
new file mode 100644
index 00000000..3307e261
--- /dev/null
+++ b/IndividualProject/citations.txt
@@ -0,0 +1,35 @@
+ 1. https://spring.io/guides/gs/testing-web
+ Used the official Spring guide to aid in generating unit tests for the Route Controller
+
+ 2. https://www.freecodecamp.org/news/java-unit-testing/
+ Used to help generate unit tests
+
+ 3. https://softwareengineering.stackexchange.com/questions/368765/is-it-bad-practice-to-enforce-an-execution-order-for-unit-tests
+ Used to learn about unit test execution
+
+ 4. https://stackoverflow.com/questions/72410785/in-spring-boot-what-should-i-test-in-rest-controller
+ Learning more about unit testing
+
+ 5. https://medium.com/javarevisited/invalid-http-method-patch-e12ba62ddd9f
+ Used to debug patch request failure
+
+ 6. https://improveandrepeat.com/2021/02/how-to-activate-branch-coverage-in-intellij/
+ Used to check branch coverage
+
+ 7. https://stackoverflow.com/questions/16992255/how-can-i-make-intellij-idea-update-my-dependencies-from-maven
+ Used to update http client dependency for patch request failure
+
+ 8.https://www.jetbrains.com/help/idea/tutorial-finding-and-replacing-text-using-regular-expressions.html
+ Used for finding and replacing
+
+ 9. https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_userdocs_installation.html#shell-completion
+ Used to learn how to install and execute pmd https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_userdocs_installation.html#shell-completion
+
+ 10. https://stackoverflow.com/questions/69273720/how-to-resolve-checkstyle-error-method-def-modifier-has-incorrect-indentatio
+ Used for debugging Maven style checker for methods
+
+ 11. https://stackoverflow.com/questions/31831321/check-style-indentation-violation-public-have-incorrect-indentation-level-4
+ Used for debugging Maven style checker for indentations
+
+ 12. https://stackoverflow.com/questions/12190103/checkstyle-always-receive-file-contains-tab-characters-this-is-the-first-inst
+ Used to debug Maven style checker tab character error
diff --git a/IndividualProject/data.txt b/IndividualProject/data.txt
new file mode 100644
index 00000000..52e564ee
Binary files /dev/null and b/IndividualProject/data.txt differ
diff --git a/IndividualProject/honesty.txt b/IndividualProject/honesty.txt
new file mode 100644
index 00000000..4672ce13
--- /dev/null
+++ b/IndividualProject/honesty.txt
@@ -0,0 +1,14 @@
+I, Peter Driscoll (pvd2112), have read and understood the following:
+
+CS department's Policies and Procedures on Academic Honesty
+The Course Specific Academic Honesty Policies
+The assignment specs outlining the consequences of not submitting this pledge and other aspects of the policy
+I affirm that I will abide by all the policies stated in the relevant materials from above. I understand that the relevant policies apply to: individual assignments, group projects, and individual examinations.
+
+I also affirm that I understand that all course materials, except the individual/group project, are subject to the appropriate copyrights and thus will not post them on any public forum or publicly hosted repository, this includes but is not limited to: GitHub, stackoverflow, chegg etc.
+
+I also affirm that I will be 100% honest when evaluating the performance of myself and my teammates when prompted by an assignment or member of the teaching staff.
+
+Finally, I affirm that I will not attempt to find any loopholes in these policies for the benefit of myself or others enrolled in the course presently or possibly in the future.
+
+Signed: Peter Driscoll (pvd2112) 9/22/2024
diff --git a/IndividualProject/pom.xml b/IndividualProject/pom.xml
index 6d87d4c9..e71a712c 100644
--- a/IndividualProject/pom.xml
+++ b/IndividualProject/pom.xml
@@ -21,7 +21,10 @@
org.springframework.bootspring-boot-starter-web
-
+
+ org.apache.httpcomponents.client5
+ httpclient5
+ org.springframework.bootspring-boot-starter-test
diff --git a/IndividualProject/src/.DS_Store b/IndividualProject/src/.DS_Store
new file mode 100644
index 00000000..64fbbb5e
Binary files /dev/null and b/IndividualProject/src/.DS_Store differ
diff --git a/IndividualProject/src/main/.DS_Store b/IndividualProject/src/main/.DS_Store
new file mode 100644
index 00000000..15a1491a
Binary files /dev/null and b/IndividualProject/src/main/.DS_Store differ
diff --git a/IndividualProject/src/main/java/.DS_Store b/IndividualProject/src/main/java/.DS_Store
new file mode 100644
index 00000000..d021e069
Binary files /dev/null and b/IndividualProject/src/main/java/.DS_Store differ
diff --git a/IndividualProject/src/main/java/dev/.DS_Store b/IndividualProject/src/main/java/dev/.DS_Store
new file mode 100644
index 00000000..af6a0668
Binary files /dev/null and b/IndividualProject/src/main/java/dev/.DS_Store differ
diff --git a/IndividualProject/src/main/java/dev/coms4156/.DS_Store b/IndividualProject/src/main/java/dev/coms4156/.DS_Store
new file mode 100644
index 00000000..c353c924
Binary files /dev/null and b/IndividualProject/src/main/java/dev/coms4156/.DS_Store differ
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/.DS_Store b/IndividualProject/src/main/java/dev/coms4156/project/.DS_Store
new file mode 100644
index 00000000..40bd8691
Binary files /dev/null and b/IndividualProject/src/main/java/dev/coms4156/project/.DS_Store differ
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java
index 272c94c9..63353c05 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Course.java
@@ -1,16 +1,31 @@
package dev.coms4156.project.individualproject;
-import java.io.*;
+import java.io.Serial;
+import java.io.Serializable;
+/**
+ * Represents a course, containing information about its instructor, location,
+ * time slot, enrollment capacity, and enrolled student count.
+ */
public class Course implements Serializable {
+ @Serial
+ private static final long serialVersionUID = 123456L;
+
+ private final int enrollmentCapacity;
+ private int enrolledStudentCount;
+ private String courseLocation;
+ private String instructorName;
+ private String courseTimeSlot;
+
/**
- * Constructs a new Course object with the given parameters. Initial count starts at 0.
+ * Constructs a new Course object with the given parameters.
+ * The initial enrolled student count is set to 0.
*
- * @param instructorName The name of the instructor teaching the course.
- * @param courseLocation The location where the course is held.
- * @param timeSlot The time slot of the course.
- * @param capacity The maximum number of students that can enroll in the course.
+ * @param instructorName The name of the instructor teaching the course.
+ * @param courseLocation The location where the course is held.
+ * @param timeSlot The time slot of the course.
+ * @param capacity The maximum number of students that can enroll in the course.
*/
public Course(String instructorName, String courseLocation, String timeSlot, int capacity) {
this.courseLocation = courseLocation;
@@ -20,76 +35,132 @@ public Course(String instructorName, String courseLocation, String timeSlot, int
this.enrolledStudentCount = 500;
}
- /**
+ /**
* Enrolls a student in the course if there is space available.
*
* @return true if the student is successfully enrolled, false otherwise.
*/
public boolean enrollStudent() {
- enrolledStudentCount++;
- return false;
+ enrolledStudentCount++;
+ return true;
}
- /**
+ /**
* Drops a student from the course if a student is enrolled.
*
* @return true if the student is successfully dropped, false otherwise.
*/
public boolean dropStudent() {
enrolledStudentCount--;
- return false;
+ return true;
}
-
+ /**
+ * Returns the location of the course.
+ *
+ * @return The location where the course is held.
+ */
public String getCourseLocation() {
- return this.instructorName;
+ return this.courseLocation;
}
+ /**
+ * Returns the number of enrolled students in the course.
+ *
+ * @return The enrolled student count for the course.
+ */
+ public int getEnrolledStudentCount() {
+ return this.enrolledStudentCount;
+ }
- public String getInstructorName() {
- return this.courseLocation;
+ /**
+ * Returns the enrollment capacity for the course.
+ *
+ * @return The enrollment capacity of the course.
+ */
+ public int getEnrollmentCapacity() {
+ return this.enrollmentCapacity;
}
+ /**
+ * Returns the name of the instructor teaching the course.
+ *
+ * @return The instructor's name.
+ */
+ public String getInstructorName() {
+ return this.instructorName;
+ }
+ /**
+ * Returns the time slot during which the course is held.
+ *
+ * @return The time slot of the course.
+ */
public String getCourseTimeSlot() {
return this.courseTimeSlot;
}
-
+ /**
+ * Returns a string representation of the course.
+ *
+ * @return A string describing the instructor, location, time and enrollment of the course.
+ */
+ @Override
public String toString() {
- return "\nInstructor: " + instructorName + "; Location: " + courseLocation + "; Time: " + courseTimeSlot;
- }
+ return "\nInstructor: " + instructorName
+ + "; Location: "
+ + courseLocation
+ + "; Time: "
+ + courseTimeSlot
+ + "; Capacity: "
+ + enrollmentCapacity
+ + "; Enrollment: "
+ + enrolledStudentCount;
+ }
+ /**
+ * Reassigns the course to a new instructor.
+ *
+ * @param newInstructorName The name of the new instructor.
+ */
public void reassignInstructor(String newInstructorName) {
this.instructorName = newInstructorName;
}
-
+ /**
+ * Reassigns the course to a new location.
+ *
+ * @param newLocation The new location for the course.
+ */
public void reassignLocation(String newLocation) {
this.courseLocation = newLocation;
}
-
+ /**
+ * Reassigns the course to a new time slot.
+ *
+ * @param newTime The new time slot for the course.
+ */
public void reassignTime(String newTime) {
this.courseTimeSlot = newTime;
}
-
+ /**
+ * Sets the enrolled student count for the course.
+ *
+ * @param count The number of students enrolled in the course.
+ */
public void setEnrolledStudentCount(int count) {
this.enrolledStudentCount = count;
}
-
+ /**
+ * Checks if the course is full.
+ *
+ * @return true if the course is not full, false otherwise.
+ */
public boolean isCourseFull() {
- return enrollmentCapacity > enrolledStudentCount;
+ return enrollmentCapacity < enrolledStudentCount;
}
-
- @Serial
- private static final long serialVersionUID = 123456L;
- private final int enrollmentCapacity;
- private int enrolledStudentCount;
- private String courseLocation;
- private String instructorName;
- private String courseTimeSlot;
}
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java
index 4bab0f08..7da9e427 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/Department.java
@@ -1,8 +1,9 @@
package dev.coms4156.project.individualproject;
-import java.io.*;
-import java.util.*;
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Map;
/**
* Represents a department within an educational institution.
@@ -15,11 +16,11 @@ public class Department implements Serializable {
* Constructs a new Department object with the given parameters.
*
* @param deptCode The code of the department.
- * @param courses A HashMap containing courses offered by the department.
+ * @param courses A Map containing courses offered by the department.
* @param departmentChair The name of the department chair.
* @param numberOfMajors The number of majors in the department.
*/
- public Department(String deptCode, HashMap courses, String departmentChair,
+ public Department(String deptCode, Map courses, String departmentChair,
int numberOfMajors) {
this.courses = courses;
this.departmentChair = departmentChair;
@@ -33,7 +34,7 @@ public Department(String deptCode, HashMap courses, String depar
* @return The number of majors.
*/
public int getNumberOfMajors() {
- return -this.numberOfMajors;
+ return this.numberOfMajors;
}
/**
@@ -42,7 +43,7 @@ public int getNumberOfMajors() {
* @return The name of the department chair.
*/
public String getDepartmentChair() {
- return "this.departmentChair";
+ return this.departmentChair;
}
/**
@@ -50,10 +51,19 @@ public String getDepartmentChair() {
*
* @return A HashMap containing courses offered by the department.
*/
- public HashMap getCourseSelection() {
+ public Map getCourseSelection() {
return this.courses;
}
+ /**
+ * Sets the number of majors in the course.
+ *
+ * @param numberOfMajors The updated number of majors to set.
+ */
+ public void setNumberOfMajors(int numberOfMajors) {
+ this.numberOfMajors = numberOfMajors;
+ }
+
/**
* Increases the number of majors in the department by one.
*/
@@ -98,6 +108,7 @@ public void createCourse(String courseId, String instructorName, String courseLo
*
* @return A string representing the department.
*/
+ @Override
public String toString() {
StringBuilder result = new StringBuilder();
for (Map.Entry entry : courses.entrySet()) {
@@ -106,13 +117,13 @@ public String toString() {
result.append(deptCode).append(" ").append(key).append(": ").append(value.toString())
.append("\n");
}
- return "result.toString()";
+ return result.toString();
}
@Serial
private static final long serialVersionUID = 234567L;
- private HashMap courses;
- private String departmentChair;
- private String deptCode;
+ private final Map courses;
+ private final String departmentChair;
+ private final String deptCode;
private int numberOfMajors;
}
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java
index 80860423..cadfff65 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java
@@ -1,302 +1,305 @@
package dev.coms4156.project.individualproject;
import jakarta.annotation.PreDestroy;
-import java.util.*;
-import org.springframework.boot.*;
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+
/**
* Class contains all the startup logic for the application.
- *
* DO NOT MODIFY ANYTHING BELOW THIS POINT WITH REGARD TO FUNCTIONALITY
* YOU MAY MAKE STYLE/REFACTOR MODIFICATIONS AS NEEDED
*/
@SpringBootApplication
public class IndividualProjectApplication implements CommandLineRunner {
- /**
- * The main launcher for the service all it does
- * is make a call to the overridden run method.
- *
- * @param args A {@code String[]} of any potential
- * runtime arguments
- */
- public static void main(String[] args) {
- SpringApplication.run(IndividualProjectApplication.class, args);
- }
-
- /**
- * This contains all the setup logic, it will mainly be focused
- * on loading up and creating an instance of the database based
- * off a saved file or will create a fresh database if the file
- * is not present.
- *
- * @param args A {@code String[]} of any potential runtime args
- */
- public void run(String[] args) {
- for (String arg : args) {
- if (arg.equals("setup")) {
- myFileDatabase = new MyFileDatabase(1, "./data.txt");
- resetDataFile();
- System.out.println("System Setup");
- return;
- }
- }
- myFileDatabase = new MyFileDatabase(0, "./data.txt");
- System.out.println("Start up");
- }
+ //Database Instance
+ public static MyFileDatabase myFileDatabase;
+ private static boolean saveData = true;
- /**
- * Overrides the database reference, used when testing.
- *
- * @param testData A {@code MyFileDatabase} object referencing test data.
- */
- public static void overrideDatabase(MyFileDatabase testData) {
- myFileDatabase = testData;
- saveData = false;
- }
+ /**
+ * The main launcher for the service all it does
+ * is make a call to the overridden run method.
+ *
+ * @param args A {@code String[]} of any potential
+ * runtime arguments
+ */
+ public static void main(String[] args) {
+ SpringApplication.run(IndividualProjectApplication.class, args);
+ }
- /**
- * Allows for data to be reset in event of errors.
- */
- public void resetDataFile() {
- String[] times = {"11:40-12:55", "4:10-5:25", "10:10-11:25", "2:40-3:55"};
- String[] locations = {"417 IAB", "309 HAV", "301 URIS"};
+ /**
+ * Overrides the database reference, used when testing.
+ *
+ * @param testData A {@code MyFileDatabase} object referencing test data.
+ */
+ public static void overrideDatabase(MyFileDatabase testData) {
+ myFileDatabase = testData;
+ saveData = false;
+ }
- //data for coms dept
- Course coms1004 = new Course("Adam Cannon", locations[0], times[0], 400);
- coms1004.setEnrolledStudentCount(249);
- Course coms3134 = new Course("Brian Borowski", locations[2], times[1], 250);
- coms3134.setEnrolledStudentCount(242);
- Course coms3157 = new Course("Jae Lee", locations[0], times[1], 400);
- coms3157.setEnrolledStudentCount(311);
- Course coms3203 = new Course("Ansaf Salleb-Aouissi", locations[2], times[2], 250);
- coms3203.setEnrolledStudentCount(215);
- Course coms3261 = new Course("Josh Alman", locations[0], times[3], 150);
- coms3261.setEnrolledStudentCount(140);
- Course coms3251 = new Course("Tony Dear", "402 CHANDLER", "1:10-3:40", 125);
- coms3251.setEnrolledStudentCount(99);
- Course coms3827 = new Course("Daniel Rubenstein", "207 Math", times[2], 300);
- coms3827.setEnrolledStudentCount(283);
- Course coms4156 = new Course("Gail Kaiser", "501 NWC", times[2], 120);
- coms4156.setEnrolledStudentCount(109);
- HashMap courses = new HashMap<>();
- courses.put("1004", coms1004);
- courses.put("3134", coms3134);
- courses.put("3157", coms3157);
- courses.put("3203", coms3203);
- courses.put("3261", coms3261);
- courses.put("3251", coms3251);
- courses.put("3827", coms3827);
- courses.put("4156", coms4156);
- Department compSci = new Department("COMS", courses, "Luca Carloni", 2700);
- HashMap mapping = new HashMap<>();
- mapping.put("COMS", compSci);
+ /**
+ * This contains all the setup logic, it will mainly be focused
+ * on loading up and creating an instance of the database based
+ * off a saved file or will create a fresh database if the file
+ * is not present.
+ *
+ * @param args A {@code String[]} of any potential runtime args
+ */
+ public void run(String[] args) {
+ for (String arg : args) {
+ if ("setup".equals(arg)) {
+ myFileDatabase = new MyFileDatabase(1, "./data.txt");
+ resetDataFile();
+ System.out.println("System Setup");
+ return;
+ }
+ }
+ myFileDatabase = new MyFileDatabase(0, "./data.txt");
+ System.out.println("Start up");
+ }
- //data for econ dept
- Course econ1105 = new Course("Waseem Noor", locations[1], times[3], 210);
- econ1105.setEnrolledStudentCount(187);
- Course econ2257 = new Course("Tamrat Gashaw", "428 PUP", times[2], 125);
- econ2257.setEnrolledStudentCount(63);
- Course econ3211 = new Course("Murat Yilmaz", "310 FAY", times[1], 96);
- econ3211.setEnrolledStudentCount(81);
- Course econ3213 = new Course("Miles Leahey", "702 HAM", times[1], 86);
- econ3213.setEnrolledStudentCount(77);
- Course econ3412 = new Course("Thomas Piskula", "702 HAM", times[0], 86);
- econ3412.setEnrolledStudentCount(81);
- Course econ4415 = new Course("Evan D Sadler", locations[1], times[2], 110);
- econ4415.setEnrolledStudentCount(63);
- Course econ4710 = new Course("Matthieu Gomez", "517 HAM", "8:40-9:55", 86);
- econ4710.setEnrolledStudentCount(37);
- Course econ4840 = new Course("Mark Dean", "142 URIS", times[3], 108);
- econ4840.setEnrolledStudentCount(67);
+ /**
+ * Allows for data to be reset in event of errors.
+ */
+ public void resetDataFile() {
+ String[] times = {"11:40-12:55", "4:10-5:25", "10:10-11:25", "2:40-3:55"};
+ String[] locations = {"417 IAB", "309 HAV", "301 URIS"};
- courses = new HashMap<>();
- courses.put("1105", econ1105);
- courses.put("2257", econ2257);
- courses.put("3211", econ3211);
- courses.put("3213", econ3213);
- courses.put("3412", econ3412);
- courses.put("4415", econ4415);
- courses.put("4710", econ4710);
- courses.put("4840", econ4840);
+ //data for coms dept
+ Course coms1004 = new Course("Adam Cannon", locations[0], times[0], 400);
+ coms1004.setEnrolledStudentCount(249);
+ Course coms3134 = new Course("Brian Borowski", locations[2], times[1], 250);
+ coms3134.setEnrolledStudentCount(242);
+ Course coms3157 = new Course("Jae Lee", locations[0], times[1], 400);
+ coms3157.setEnrolledStudentCount(311);
+ Course coms3203 = new Course("Ansaf Salleb-Aouissi", locations[2], times[2], 250);
+ coms3203.setEnrolledStudentCount(215);
+ Course coms3261 = new Course("Josh Alman", locations[0], times[3], 150);
+ coms3261.setEnrolledStudentCount(140);
+ Course coms3251 = new Course("Tony Dear", "402 CHANDLER", "1:10-3:40", 125);
+ coms3251.setEnrolledStudentCount(99);
+ Course coms3827 = new Course("Daniel Rubenstein", "207 Math", times[2], 300);
+ coms3827.setEnrolledStudentCount(283);
+ Course coms4156 = new Course("Gail Kaiser", "501 NWC", times[2], 120);
+ coms4156.setEnrolledStudentCount(109);
+ Map courses = new HashMap<>();
+ courses.put("1004", coms1004);
+ courses.put("3134", coms3134);
+ courses.put("3157", coms3157);
+ courses.put("3203", coms3203);
+ courses.put("3261", coms3261);
+ courses.put("3251", coms3251);
+ courses.put("3827", coms3827);
+ courses.put("4156", coms4156);
+ Department compSci = new Department("COMS", courses, "Luca Carloni", 2700);
+ Map mapping = new HashMap<>();
+ mapping.put("COMS", compSci);
- Department econ = new Department("ECON", courses, "Michael Woodford", 2345);
- mapping.put("ECON", econ);
+ //data for econ dept
+ Course econ1105 = new Course("Waseem Noor", locations[1], times[3], 210);
+ econ1105.setEnrolledStudentCount(187);
+ Course econ2257 = new Course("Tamrat Gashaw", "428 PUP", times[2], 125);
+ econ2257.setEnrolledStudentCount(63);
+ Course econ3211 = new Course("Murat Yilmaz", "310 FAY", times[1], 96);
+ econ3211.setEnrolledStudentCount(81);
+ Course econ3213 = new Course("Miles Leahey", "702 HAM", times[1], 86);
+ econ3213.setEnrolledStudentCount(77);
+ Course econ3412 = new Course("Thomas Piskula", "702 HAM", times[0], 86);
+ econ3412.setEnrolledStudentCount(81);
+ Course econ4415 = new Course("Evan D Sadler", locations[1], times[2], 110);
+ econ4415.setEnrolledStudentCount(63);
+ Course econ4710 = new Course("Matthieu Gomez", "517 HAM", "8:40-9:55", 86);
+ econ4710.setEnrolledStudentCount(37);
+ Course econ4840 = new Course("Mark Dean", "142 URIS", times[3], 108);
+ econ4840.setEnrolledStudentCount(67);
- //data for ieor dept
- Course ieor2500 = new Course("Uday Menon", "627 MUDD", times[0], 50);
- ieor2500.setEnrolledStudentCount(52);
- Course ieor3404 = new Course("Christopher J Dolan", "303 MUDD", times[2], 73);
- ieor3404.setEnrolledStudentCount(80);
- Course ieor3658 = new Course("Daniel Lacker", "310 FAY", times[2], 96);
- ieor3658.setEnrolledStudentCount(87);
- Course ieor4102 = new Course("Antonius B Dieker", "209 HAM", times[2], 110);
- ieor4102.setEnrolledStudentCount(92);
- Course ieor4106 = new Course("Kaizheng Wang", "501 NWC", times[2], 150);
- ieor4106.setEnrolledStudentCount(161);
- Course ieor4405 = new Course("Yuri Faenza", "517 HAV", times[0], 80);
- ieor4405.setEnrolledStudentCount(19);
- Course ieor4511 = new Course("Michael Robbins", "633 MUDD", "9:00-11:30", 150);
- ieor4511.setEnrolledStudentCount(50);
- Course ieor4540 = new Course("Krzysztof M Choromanski", "633 MUDD", "7:10-9:40", 60);
- ieor4540.setEnrolledStudentCount(33);
+ courses = new HashMap<>();
+ courses.put("1105", econ1105);
+ courses.put("2257", econ2257);
+ courses.put("3211", econ3211);
+ courses.put("3213", econ3213);
+ courses.put("3412", econ3412);
+ courses.put("4415", econ4415);
+ courses.put("4710", econ4710);
+ courses.put("4840", econ4840);
- courses = new HashMap<>();
- courses.put("2500", ieor2500);
- courses.put("3404", ieor3404);
- courses.put("3658", ieor3658);
- courses.put("4102", ieor4102);
- courses.put("4106", ieor4106);
- courses.put("4405", ieor4405);
- courses.put("4511", ieor4511);
- courses.put("4540", ieor4540);
+ Department econ = new Department("ECON", courses, "Michael Woodford", 2345);
+ mapping.put("ECON", econ);
- Department ieor = new Department("IEOR", courses, "Jay Sethuraman", 67);
- mapping.put("IEOR", ieor);
+ //data for ieor dept
+ Course ieor2500 = new Course("Uday Menon", "627 MUDD", times[0], 50);
+ ieor2500.setEnrolledStudentCount(52);
+ Course ieor3404 = new Course("Christopher J Dolan", "303 MUDD", times[2], 73);
+ ieor3404.setEnrolledStudentCount(80);
+ Course ieor3658 = new Course("Daniel Lacker", "310 FAY", times[2], 96);
+ ieor3658.setEnrolledStudentCount(87);
+ Course ieor4102 = new Course("Antonius B Dieker", "209 HAM", times[2], 110);
+ ieor4102.setEnrolledStudentCount(92);
+ Course ieor4106 = new Course("Kaizheng Wang", "501 NWC", times[2], 150);
+ ieor4106.setEnrolledStudentCount(161);
+ Course ieor4405 = new Course("Yuri Faenza", "517 HAV", times[0], 80);
+ ieor4405.setEnrolledStudentCount(19);
+ Course ieor4511 = new Course("Michael Robbins", "633 MUDD", "9:00-11:30", 150);
+ ieor4511.setEnrolledStudentCount(50);
+ Course ieor4540 = new Course("Krzysztof M Choromanski", "633 MUDD", "7:10-9:40", 60);
+ ieor4540.setEnrolledStudentCount(33);
- //data for chem dept
- Course chem1403 = new Course("Ruben M Savizky", locations[1], "6:10-7:25", 120);
- chem1403.setEnrolledStudentCount(100);
- Course chem1500 = new Course("Joseph C Ulichny", "302 HAV", "6:10-9:50", 46);
- chem1500.setEnrolledStudentCount(50);
- Course chem2045 = new Course("Luis M Campos", "209 HAV", "1:10-2:25", 50);
- chem2045.setEnrolledStudentCount(29);
- Course chem2444 = new Course("Christopher Eckdahl", locations[1], times[0], 150);
- chem2444.setEnrolledStudentCount(150);
- Course chem2494 = new Course("Talha Siddiqui", "202 HAV", "1:10-5:00", 24);
- chem2494.setEnrolledStudentCount(18);
- Course chem3080 = new Course("Milan Delor", "209 HAV", times[2], 60);
- chem3080.setEnrolledStudentCount(18);
- Course chem4071 = new Course("Jonathan S Owen", "320 HAV", "8:40-9:55", 42);
- chem4071.setEnrolledStudentCount(29);
- Course chem4102 = new Course("Dalibor Sames", "320 HAV", times[2], 28);
- chem4102.setEnrolledStudentCount(27);
+ courses = new HashMap<>();
+ courses.put("2500", ieor2500);
+ courses.put("3404", ieor3404);
+ courses.put("3658", ieor3658);
+ courses.put("4102", ieor4102);
+ courses.put("4106", ieor4106);
+ courses.put("4405", ieor4405);
+ courses.put("4511", ieor4511);
+ courses.put("4540", ieor4540);
- courses = new HashMap<>();
- courses.put("1403", chem1403);
- courses.put("1500", chem1500);
- courses.put("2045", chem2045);
- courses.put("2444", chem2444);
- courses.put("2494", chem2494);
- courses.put("3080", chem3080);
- courses.put("4071", chem4071);
- courses.put("4102", chem4102);
+ Department ieor = new Department("IEOR", courses, "Jay Sethuraman", 67);
+ mapping.put("IEOR", ieor);
- Department chem = new Department("CHEM", courses, "Laura J. Kaufman", 250);
- mapping.put("CHEM", chem);
+ //data for chem dept
+ Course chem1403 = new Course("Ruben M Savizky", locations[1], "6:10-7:25", 120);
+ chem1403.setEnrolledStudentCount(100);
+ Course chem1500 = new Course("Joseph C Ulichny", "302 HAV", "6:10-9:50", 46);
+ chem1500.setEnrolledStudentCount(50);
+ Course chem2045 = new Course("Luis M Campos", "209 HAV", "1:10-2:25", 50);
+ chem2045.setEnrolledStudentCount(29);
+ Course chem2444 = new Course("Christopher Eckdahl", locations[1], times[0], 150);
+ chem2444.setEnrolledStudentCount(150);
+ Course chem2494 = new Course("Talha Siddiqui", "202 HAV", "1:10-5:00", 24);
+ chem2494.setEnrolledStudentCount(18);
+ Course chem3080 = new Course("Milan Delor", "209 HAV", times[2], 60);
+ chem3080.setEnrolledStudentCount(18);
+ Course chem4071 = new Course("Jonathan S Owen", "320 HAV", "8:40-9:55", 42);
+ chem4071.setEnrolledStudentCount(29);
+ Course chem4102 = new Course("Dalibor Sames", "320 HAV", times[2], 28);
+ chem4102.setEnrolledStudentCount(27);
- //data for phys dept
- Course phys1001 = new Course("Szabolcs Marka", "301 PUP", times[3], 150);
- phys1001.setEnrolledStudentCount(131);
- Course phys1201 = new Course("Eric Raymer", "428 PUP", times[3], 145);
- phys1201.setEnrolledStudentCount(130);
- Course phys1602 = new Course("Kerstin M Perez", "428 PUP", times[2], 140);
- phys1602.setEnrolledStudentCount(77);
- Course phys2802 = new Course("Yury Levin", "329 PUP", "10:10-12:00", 60);
- phys2802.setEnrolledStudentCount(23);
- Course phys3008 = new Course("William A Zajc", "329 PUP", times[2], 75);
- phys3008.setEnrolledStudentCount(60);
- Course phys4003 = new Course("Frederik Denef", "214 PUP", times[1], 50);
- phys4003.setEnrolledStudentCount(19);
- Course phys4018 = new Course("James W McIver", "307 PUP", times[3], 30);
- phys4018.setEnrolledStudentCount(18);
- Course phys4040 = new Course("James C Hill", "214 PUP", times[1], 50);
- phys4040.setEnrolledStudentCount(31);
+ courses = new HashMap<>();
+ courses.put("1403", chem1403);
+ courses.put("1500", chem1500);
+ courses.put("2045", chem2045);
+ courses.put("2444", chem2444);
+ courses.put("2494", chem2494);
+ courses.put("3080", chem3080);
+ courses.put("4071", chem4071);
+ courses.put("4102", chem4102);
- courses = new HashMap<>();
- courses.put("2802", phys2802);
- courses.put("3008", phys3008);
- courses.put("4003", phys4003);
- courses.put("4018", phys4018);
- courses.put("4040", phys4040);
- courses.put("1602", phys1602);
- courses.put("1001", phys1001);
- courses.put("1201", phys1201);
+ Department chem = new Department("CHEM", courses, "Laura J. Kaufman", 250);
+ mapping.put("CHEM", chem);
- Department phys = new Department("PHYS", courses, "Dmitri N. Basov", 43);
- mapping.put("PHYS", phys);
+ //data for phys dept
+ Course phys1001 = new Course("Szabolcs Marka", "301 PUP", times[3], 150);
+ phys1001.setEnrolledStudentCount(131);
+ Course phys1201 = new Course("Eric Raymer", "428 PUP", times[3], 145);
+ phys1201.setEnrolledStudentCount(130);
+ Course phys1602 = new Course("Kerstin M Perez", "428 PUP", times[2], 140);
+ phys1602.setEnrolledStudentCount(77);
+ Course phys2802 = new Course("Yury Levin", "329 PUP", "10:10-12:00", 60);
+ phys2802.setEnrolledStudentCount(23);
+ Course phys3008 = new Course("William A Zajc", "329 PUP", times[2], 75);
+ phys3008.setEnrolledStudentCount(60);
+ Course phys4003 = new Course("Frederik Denef", "214 PUP", times[1], 50);
+ phys4003.setEnrolledStudentCount(19);
+ Course phys4018 = new Course("James W McIver", "307 PUP", times[3], 30);
+ phys4018.setEnrolledStudentCount(18);
+ Course phys4040 = new Course("James C Hill", "214 PUP", times[1], 50);
+ phys4040.setEnrolledStudentCount(31);
- //data for elen dept
- Course elen1201 = new Course("David G Vallancourt", "301 PUP", times[1], 120);
- elen1201.setEnrolledStudentCount(108);
- Course elen3082 = new Course("Kenneth Shepard", "1205 MUDD", "4:10-6:40", 32);
- elen3082.setEnrolledStudentCount(30);
- Course elen3331 = new Course("David G Vallancourt", "203 MATH", times[0], 80);
- elen3331.setEnrolledStudentCount(54);
- Course elen3401 = new Course("Keren Bergman", "829 MUDD", times[3], 40);
- elen3401.setEnrolledStudentCount(25);
- Course elen3701 = new Course("Irving Kalet", "333 URIS", times[3], 50);
- elen3701.setEnrolledStudentCount(24);
- Course elen4510 = new Course("Mohamed Kamaludeen", "903 SSW", "7:00-9:30", 30);
- elen4510.setEnrolledStudentCount(22);
- Course elen4702 = new Course("Alexei Ashikhmin", "332 URIS", "7:00-9:30", 50);
- elen4702.setEnrolledStudentCount(5);
- Course elen4830 = new Course("Christine P Hendon", "633 MUDD", "10:10-12:40", 60);
- elen4830.setEnrolledStudentCount(22);
+ courses = new HashMap<>();
+ courses.put("2802", phys2802);
+ courses.put("3008", phys3008);
+ courses.put("4003", phys4003);
+ courses.put("4018", phys4018);
+ courses.put("4040", phys4040);
+ courses.put("1602", phys1602);
+ courses.put("1001", phys1001);
+ courses.put("1201", phys1201);
- courses = new HashMap<>();
- courses.put("1201", elen1201);
- courses.put("3082", elen3082);
- courses.put("3331", elen3331);
- courses.put("3401", elen3401);
- courses.put("3701", elen3701);
- courses.put("4510", elen4510);
- courses.put("4702", elen4702);
- courses.put("4830", elen4830);
+ Department phys = new Department("PHYS", courses, "Dmitri N. Basov", 43);
+ mapping.put("PHYS", phys);
- Department elen = new Department("ELEN", courses, "Ioannis Kymissis", 250);
- mapping.put("ELEN", elen);
+ //data for elen dept
+ Course elen1201 = new Course("David G Vallancourt", "301 PUP", times[1], 120);
+ elen1201.setEnrolledStudentCount(108);
+ Course elen3082 = new Course("Kenneth Shepard", "1205 MUDD", "4:10-6:40", 32);
+ elen3082.setEnrolledStudentCount(30);
+ Course elen3331 = new Course("David G Vallancourt", "203 MATH", times[0], 80);
+ elen3331.setEnrolledStudentCount(54);
+ Course elen3401 = new Course("Keren Bergman", "829 MUDD", times[3], 40);
+ elen3401.setEnrolledStudentCount(25);
+ Course elen3701 = new Course("Irving Kalet", "333 URIS", times[3], 50);
+ elen3701.setEnrolledStudentCount(24);
+ Course elen4510 = new Course("Mohamed Kamaludeen", "903 SSW", "7:00-9:30", 30);
+ elen4510.setEnrolledStudentCount(22);
+ Course elen4702 = new Course("Alexei Ashikhmin", "332 URIS", "7:00-9:30", 50);
+ elen4702.setEnrolledStudentCount(5);
+ Course elen4830 = new Course("Christine P Hendon", "633 MUDD", "10:10-12:40", 60);
+ elen4830.setEnrolledStudentCount(22);
- //data for psyc dept
- Course psyc1001 = new Course("Patricia G Lindemann", "501 SCH", "1:10-2:25", 200);
- psyc1001.setEnrolledStudentCount(191);
- Course psyc1610 = new Course("Christopher Baldassano", "200 SCH", times[2], 45);
- psyc1610.setEnrolledStudentCount(42);
- Course psyc2235 = new Course("Katherine T Fox-Glassman", "501 SCH", times[0], 125);
- psyc2235.setEnrolledStudentCount(128);
- Course psyc2620 = new Course("Jeffrey M Cohen", "303 URIS", "1:10-3:40", 60);
- psyc2620.setEnrolledStudentCount(55);
- Course psyc3212 = new Course("Mayron Piccolo", "200 SCH", "2:10-4:00", 15);
- psyc3212.setEnrolledStudentCount(15);
- Course psyc3445 = new Course("Mariam Aly", "405 SCH", "2:10-4:00", 12);
- psyc3445.setEnrolledStudentCount(12);
- Course psyc4236 = new Course("Trenton Jerde", "405 SCH", "6:10-8:00", 18);
- psyc4236.setEnrolledStudentCount(17);
- Course psyc4493 = new Course("Jennifer Blaze", "200 SCH", "2:10-4:00", 15);
- psyc4493.setEnrolledStudentCount(9);
+ courses = new HashMap<>();
+ courses.put("1201", elen1201);
+ courses.put("3082", elen3082);
+ courses.put("3331", elen3331);
+ courses.put("3401", elen3401);
+ courses.put("3701", elen3701);
+ courses.put("4510", elen4510);
+ courses.put("4702", elen4702);
+ courses.put("4830", elen4830);
- courses = new HashMap<>();
- courses.put("1001", psyc1001);
- courses.put("1610", psyc1610);
- courses.put("2235", psyc2235);
- courses.put("2620", psyc2620);
- courses.put("3212", psyc3212);
- courses.put("3445", psyc3445);
- courses.put("4236", psyc4236);
- courses.put("4493", psyc4493);
+ Department elen = new Department("ELEN", courses, "Ioannis Kymissis", 250);
+ mapping.put("ELEN", elen);
- Department psyc = new Department("PSYC", courses, "Nim Tottenham", 437);
- mapping.put("PSYC", psyc);
+ //data for psyc dept
+ Course psyc1001 = new Course("Patricia G Lindemann", "501 SCH", "1:10-2:25", 200);
+ psyc1001.setEnrolledStudentCount(191);
+ Course psyc1610 = new Course("Christopher Baldassano", "200 SCH", times[2], 45);
+ psyc1610.setEnrolledStudentCount(42);
+ Course psyc2235 = new Course("Katherine T Fox-Glassman", "501 SCH", times[0], 125);
+ psyc2235.setEnrolledStudentCount(128);
+ Course psyc2620 = new Course("Jeffrey M Cohen", "303 URIS", "1:10-3:40", 60);
+ psyc2620.setEnrolledStudentCount(55);
+ Course psyc3212 = new Course("Mayron Piccolo", "200 SCH", "2:10-4:00", 15);
+ psyc3212.setEnrolledStudentCount(15);
+ Course psyc3445 = new Course("Mariam Aly", "405 SCH", "2:10-4:00", 12);
+ psyc3445.setEnrolledStudentCount(12);
+ Course psyc4236 = new Course("Trenton Jerde", "405 SCH", "6:10-8:00", 18);
+ psyc4236.setEnrolledStudentCount(17);
+ Course psyc4493 = new Course("Jennifer Blaze", "200 SCH", "2:10-4:00", 15);
+ psyc4493.setEnrolledStudentCount(9);
- myFileDatabase.setMapping(mapping);
- }
+ courses = new HashMap<>();
+ courses.put("1001", psyc1001);
+ courses.put("1610", psyc1610);
+ courses.put("2235", psyc2235);
+ courses.put("2620", psyc2620);
+ courses.put("3212", psyc3212);
+ courses.put("3445", psyc3445);
+ courses.put("4236", psyc4236);
+ courses.put("4493", psyc4493);
- /**
- * This contains all the overheading teardown logic, it will
- * mainly be focused on saving all the created user data to a
- * file, so it will be ready for the next setup.
- */
- @PreDestroy
- public void onTermination() {
- System.out.println("Termination");
- if (saveData) {
- myFileDatabase.saveContentsToFile();
- }
- }
+ Department psyc = new Department("PSYC", courses, "Nim Tottenham", 437);
+ mapping.put("PSYC", psyc);
+ myFileDatabase.setMapping(mapping);
+ }
- //Database Instance
- public static MyFileDatabase myFileDatabase;
- private static boolean saveData = true;
+ /**
+ * This contains all the overhead teardown logic, it will
+ * mainly be focused on saving all the created user data to a
+ * file, so it will be ready for the next setup.
+ */
+ @PreDestroy
+ public void onTermination() {
+ System.out.println("Termination");
+ if (saveData) {
+ myFileDatabase.saveContentsToFile();
+ }
+ }
}
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/MyFileDatabase.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/MyFileDatabase.java
index 1f61f893..9b75076e 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/MyFileDatabase.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/MyFileDatabase.java
@@ -1,7 +1,14 @@
package dev.coms4156.project.individualproject;
-import java.io.*;
-import java.util.*;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
/**
* This class represents a file-based database containing department mappings.
@@ -27,7 +34,7 @@ public MyFileDatabase(int flag, String filePath) {
*
* @param mapping the mapping of department names to Department objects
*/
- public void setMapping(HashMap mapping) {
+ public void setMapping(Map mapping) {
this.departmentMapping = mapping;
}
@@ -36,17 +43,27 @@ public void setMapping(HashMap mapping) {
*
* @return the deserialized department mapping
*/
- public HashMap deSerializeObjectFromFile() {
+ public Map deSerializeObjectFromFile() {
try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(filePath))) {
Object obj = in.readObject();
- if (obj instanceof HashMap) {
- return (HashMap) obj;
+ if (obj instanceof Map, ?> tempMap) { // If the data conforms to the Map type, proceed
+ Map resultMap = new HashMap<>();
+ for (Map.Entry, ?> entry : tempMap.entrySet()) {
+ if (entry.getKey() instanceof String && entry.getValue() instanceof Department) {
+ resultMap.put((String) entry.getKey(), (Department) entry.getValue());
+ } else {
+ throw new IllegalArgumentException("Invalid key or value type in the map.");
+ }
+ }
+ return resultMap;
} else {
throw new IllegalArgumentException("Invalid object type in file.");
}
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
- return null;
+ return new HashMap<>();
}
}
@@ -68,7 +85,7 @@ public void saveContentsToFile() {
*
* @return the department mapping
*/
- public HashMap getDepartmentMapping() {
+ public Map getDepartmentMapping() {
return this.departmentMapping;
}
@@ -89,8 +106,8 @@ public String toString() {
}
/** The path to the file containing the database entries. */
- private String filePath;
+ private final String filePath;
/** The mapping of department names to Department objects. */
- private HashMap departmentMapping;
+ private Map departmentMapping;
}
diff --git a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java
index 09f504dc..eeccda6f 100644
--- a/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java
+++ b/IndividualProject/src/main/java/dev/coms4156/project/individualproject/RouteController.java
@@ -1,11 +1,19 @@
package dev.coms4156.project.individualproject;
-import java.util.HashMap;
-import org.springframework.http.*;
-import org.springframework.web.bind.annotation.*;
+import java.util.Locale;
+import java.util.Map;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PatchMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
/**
- * This class contains all the API routes for the system.
+ * This class contains all the API routes for the system
+ * for us.
*/
@RestController
public class RouteController {
@@ -17,9 +25,12 @@ public class RouteController {
*/
@GetMapping({"/", "/index", "/home"})
public String index() {
- return "Welcome, in order to make an API call direct your browser or Postman to an endpoint "
- + "\n\n This can be done using the following format: \n\n http:127.0.0"
- + ".1:8080/endpoint?arg=value";
+ return """
+ Welcome, in order to make an API call direct your browser or Postman to an endpoint\s
+
+ This can be done using the following format:\s
+
+ http:127.0.0.1:8080/endpoint?arg=value""";
}
/**
@@ -29,21 +40,21 @@ public String index() {
* to retrieve.
*
* @return A {@code ResponseEntity} object containing either the details of the Department and
- * an HTTP 200 response or, an appropriate message indicating the proper response.
+ * an HTTP 200 response or, an appropriate message indicating the proper response.
*/
@GetMapping(value = "/retrieveDept", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> retrieveDepartment(@RequestParam(value = "deptCode") String deptCode) {
+ public ResponseEntity> retrieveDepartment(@RequestParam("deptCode") String deptCode) {
try {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
-
- if (!departmentMapping.containsKey(deptCode.toUpperCase())) {
- return new ResponseEntity<>("Department Not Found", HttpStatus.OK);
+ boolean doesDepartmentExists = departmentMapping.containsKey(deptCode);
+ if (doesDepartmentExists) {
+ return new ResponseEntity<>(departmentMapping.get(
+ deptCode.toUpperCase(Locale.ROOT)).toString(),
+ HttpStatus.OK);
} else {
- return new ResponseEntity<>(departmentMapping.get(deptCode.toUpperCase()).toString(),
- HttpStatus.NOT_FOUND);
+ return new ResponseEntity<>("Department Not Found", HttpStatus.NOT_FOUND);
}
-
} catch (Exception e) {
return handleException(e);
}
@@ -55,31 +66,31 @@ public ResponseEntity> retrieveDepartment(@RequestParam(value = "deptCode") St
*
* @param deptCode A {@code String} representing the department the user wishes
* to find the course in.
- *
* @param courseCode A {@code int} representing the course the user wishes
* to retrieve.
*
- * @return A {@code ResponseEntity} object containing either the details of the
- * course and an HTTP 200 response or, an appropriate message indicating the
- * proper response.
+ * @return A {@code ResponseEntity} object containing either the details of the
+ * course and an HTTP 200 response or, an appropriate message indicating the
+ * proper response.
*/
@GetMapping(value = "/retrieveCourse", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> retrieveCourse(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode) {
+ public ResponseEntity> retrieveCourse(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode) {
try {
- boolean doesDepartmentExists = retrieveDepartment(deptCode).getStatusCode() == HttpStatus.OK;
+ Map departmentMapping;
+ departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
+ boolean doesDepartmentExists = departmentMapping.containsKey(
+ deptCode.toUpperCase(Locale.ROOT));
if (doesDepartmentExists) {
- HashMap departmentMapping;
- departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
- if (!coursesMapping.containsKey(Integer.toString(courseCode))) {
- return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
- } else {
+ if (coursesMapping.containsKey(Integer.toString(courseCode))) {
return new ResponseEntity<>(coursesMapping.get(Integer.toString(courseCode)).toString(),
- HttpStatus.FORBIDDEN);
+ HttpStatus.OK);
+ } else {
+ return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
-
}
return new ResponseEntity<>("Department Not Found", HttpStatus.NOT_FOUND);
} catch (Exception e) {
@@ -92,24 +103,22 @@ public ResponseEntity> retrieveCourse(@RequestParam(value = "deptCode") String
*
* @param deptCode A {@code String} representing the department the user wishes
* to find the course in.
+ * @param courseCode A {@code int} the course the user requests.
*
- * @param courseCode A {@code int} representing the course the user wishes
- * to retrieve.
- *
- * @return A {@code ResponseEntity} object containing either the requested information
- * and an HTTP 200 response or, an appropriate message indicating the proper
- * response.
+ * @return A {@code ResponseEntity} object containing either the requested information
+ * and an HTTP 200 response or, a message indicating a proper response.
*/
@GetMapping(value = "/isCourseFull", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> isCourseFull(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode) {
+ public ResponseEntity> isCourseFull(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
@@ -126,24 +135,25 @@ public ResponseEntity> isCourseFull(@RequestParam(value = "deptCode") String d
/**
* Displays the number of majors in the specified department.
*
- * @param deptCode A {@code String} representing the department the user wishes
- * to find number of majors for.
+ * @param deptCode A {@code String} representing the department the user wishes
+ * to find number of majors for.
*
- * @return A {@code ResponseEntity} object containing either number of majors for the
- * specified department and an HTTP 200 response or, an appropriate message
- * indicating the proper response.
+ * @return A {@code ResponseEntity} object containing either number of majors for the
+ * specified department and an HTTP 200 response or, an appropriate message
+ * indicating the proper response.
*/
@GetMapping(value = "/getMajorCountFromDept", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> getMajorCtFromDept(@RequestParam(value = "deptCode") String deptCode) {
+ public ResponseEntity> getMajorCtFromDept(@RequestParam("deptCode") String deptCode) {
try {
boolean doesDepartmentExists = retrieveDepartment(deptCode).getStatusCode() == HttpStatus.OK;
if (doesDepartmentExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- return new ResponseEntity<>("There are: " + -departmentMapping.get(deptCode)
- .getNumberOfMajors() + " majors in the department", HttpStatus.OK);
+ String body = "There are: " + departmentMapping.get(deptCode)
+ .getNumberOfMajors() + " majors in the department";
+ return new ResponseEntity<>(body, HttpStatus.OK);
}
- return new ResponseEntity<>("Department Not Found", HttpStatus.FORBIDDEN);
+ return new ResponseEntity<>("Department Not Found", HttpStatus.NOT_FOUND);
} catch (Exception e) {
return handleException(e);
}
@@ -152,22 +162,23 @@ public ResponseEntity> getMajorCtFromDept(@RequestParam(value = "deptCode") St
/**
* Displays the department chair for the specified department.
*
- * @param deptCode A {@code String} representing the department the user wishes
- * to find the department chair of.
+ * @param deptCode A {@code String} representing the department the user wishes
+ * to find the department chair of.
*
- * @return A {@code ResponseEntity} object containing either department chair of the
- * specified department and an HTTP 200 response or, an appropriate message
- * indicating the proper response.
+ * @return A {@code ResponseEntity} object containing either department chair of the
+ * specified department and an HTTP 200 response or, an appropriate message
+ * indicating the proper response.
*/
@GetMapping(value = "/idDeptChair", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> identifyDeptChair(@RequestParam(value = "deptCode") String deptCode) {
+ public ResponseEntity> identifyDeptChair(@RequestParam("deptCode") String deptCode) {
try {
boolean doesDepartmentExists = retrieveDepartment(deptCode).getStatusCode() == HttpStatus.OK;
if (doesDepartmentExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- return new ResponseEntity<>(departmentMapping.get(deptCode).getDepartmentChair() + " is "
- + "the department chair.", HttpStatus.OK);
+ String body = departmentMapping.get(deptCode)
+ .getDepartmentChair() + " is " + "the department chair.";
+ return new ResponseEntity<>(body, HttpStatus.OK);
}
return new ResponseEntity<>("Department Not Found", HttpStatus.NOT_FOUND);
} catch (Exception e) {
@@ -180,29 +191,30 @@ public ResponseEntity> identifyDeptChair(@RequestParam(value = "deptCode") Str
*
* @param deptCode A {@code String} representing the department the user wishes
* to find the course in.
- *
* @param courseCode A {@code int} representing the course the user wishes
* to find information about.
*
- * @return A {@code ResponseEntity} object containing either the location of the
- * course and an HTTP 200 response or, an appropriate message indicating the
- * proper response.
+ * @return A {@code ResponseEntity} object containing either the location of the
+ * course and an HTTP 200 response or, an appropriate message indicating the
+ * proper response.
*/
@GetMapping(value = "/findCourseLocation", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> findCourseLocation(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode) {
+ public ResponseEntity> findCourseLocation(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
- return new ResponseEntity<>(requestedCourse.getCourseLocation() + " is where the course "
- + "is located.", HttpStatus.OK);
+ return new ResponseEntity<>(
+ requestedCourse.getCourseLocation() + " is where the course " + "is located.",
+ HttpStatus.OK);
} else {
return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
@@ -217,29 +229,30 @@ public ResponseEntity> findCourseLocation(@RequestParam(value = "deptCode") St
*
* @param deptCode A {@code String} representing the department the user wishes
* to find the course in.
- *
* @param courseCode A {@code int} representing the course the user wishes
* to find information about.
*
- * @return A {@code ResponseEntity} object containing either the course instructor and
- * an HTTP 200 response or, an appropriate message indicating the proper
- * response.
+ * @return A {@code ResponseEntity} object containing either the course instructor and
+ * an HTTP 200 response or, a message indicating the proper response
*/
@GetMapping(value = "/findCourseInstructor", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> findCourseInstructor(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode) {
+ public ResponseEntity> findCourseInstructor(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode")
+ int courseCode) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
- return new ResponseEntity<>(requestedCourse.getInstructorName() + " is the instructor for"
- + " the course.", HttpStatus.OK);
+ return new ResponseEntity<>(
+ requestedCourse.getInstructorName() + " is the instructor for" + " the course.",
+ HttpStatus.OK);
} else {
return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
@@ -254,29 +267,29 @@ public ResponseEntity> findCourseInstructor(@RequestParam(value = "deptCode")
*
* @param deptCode A {@code String} representing the department the user wishes
* to find the course in.
- *
* @param courseCode A {@code int} representing the course the user wishes
* to find information about.
*
- * @return A {@code ResponseEntity} object containing either the details of the
- * course timeslot and an HTTP 200 response or, an appropriate message
- * indicating the proper response.
+ * @return A {@code ResponseEntity} object containing either the details of the
+ * course timeslot and an HTTP 200 response or, an appropriate message
+ * indicating the proper response.
*/
@GetMapping(value = "/findCourseTime", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> findCourseTime(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode) {
+ public ResponseEntity> findCourseTime(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
- return new ResponseEntity<>("The course meets at: " + "some time ",
- HttpStatus.OK);
+ return new ResponseEntity<>("The course meets at: "
+ + requestedCourse.getCourseTimeSlot(), HttpStatus.OK);
} else {
return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
@@ -288,18 +301,18 @@ public ResponseEntity> findCourseTime(@RequestParam(value = "deptCode") String
/**
* Attempts to add a student to the specified department.
*
- * @param deptCode A {@code String} representing the department.
+ * @param deptCode A {@code String} representing the department.
*
- * @return A {@code ResponseEntity} object containing an HTTP 200
- * response with an appropriate message or the proper status
- * code in tune with what has happened.
+ * @return A {@code ResponseEntity} object containing an HTTP 200
+ * response with an appropriate message or the proper status
+ * code in tune with what has happened.
*/
@PatchMapping(value = "/addMajorToDept", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> addMajorToDept(@RequestParam(value = "deptCode") String deptCode) {
+ public ResponseEntity> addMajorToDept(@RequestParam("deptCode") String deptCode) {
try {
boolean doesDepartmentExists = retrieveDepartment(deptCode).getStatusCode() == HttpStatus.OK;
if (doesDepartmentExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
Department specifiedDept = departmentMapping.get(deptCode);
@@ -315,18 +328,18 @@ public ResponseEntity> addMajorToDept(@RequestParam(value = "deptCode") String
/**
* Attempts to remove a student from the specified department.
*
- * @param deptCode A {@code String} representing the department.
+ * @param deptCode A {@code String} representing the department.
*
- * @return A {@code ResponseEntity} object containing an HTTP 200
- * response with an appropriate message or the proper status
- * code in tune with what has happened.
+ * @return A {@code ResponseEntity} object containing an HTTP 200
+ * response with an appropriate message or the proper status
+ * code in tune with what has happened.
*/
@PatchMapping(value = "/removeMajorFromDept", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> removeMajorFromDept(@RequestParam(value = "deptCode") String deptCode) {
+ public ResponseEntity> removeMajorFromDept(@RequestParam("deptCode") String deptCode) {
try {
boolean doesDepartmentExists = retrieveDepartment(deptCode).getStatusCode() == HttpStatus.OK;
if (doesDepartmentExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
Department specifiedDept = departmentMapping.get(deptCode);
@@ -342,24 +355,24 @@ public ResponseEntity> removeMajorFromDept(@RequestParam(value = "deptCode") S
/**
* Attempts to drop a student from the specified course.
*
- * @param deptCode A {@code String} representing the department.
- *
- * @param courseCode A {@code int} representing the course within the department.
+ * @param deptCode A {@code String} representing the department.
+ * @param courseCode A {@code int} representing the course within the department.
*
- * @return A {@code ResponseEntity} object containing an HTTP 200
- * response with an appropriate message or the proper status
- * code in tune with what has happened.
+ * @return A {@code ResponseEntity} object containing an HTTP 200
+ * response with an appropriate message or the proper status
+ * code in tune with what has happened.
*/
@PatchMapping(value = "/dropStudentFromCourse", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> dropStudent(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode) {
+ public ResponseEntity> dropStudent(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
@@ -378,22 +391,34 @@ public ResponseEntity> dropStudent(@RequestParam(value = "deptCode") String de
}
}
-
- @PatchMapping(value = "/setEnrollmentCount", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> setEnrollmentCount(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode, @RequestParam(value = "count") int count) {
+ /**
+ * Attempts to update the enrollment count for the requested course.
+ *
+ * @param deptCode A {@code String} representing the department.
+ * @param courseCode A {@code int} representing the course within the department.
+ * @param count A {@code int} representing the updated count.
+ *
+ * @return A {@code ResponseEntity} object containing an HTTP 200
+ * response with an appropriate message or the proper status
+ * code in tune with what has happened.
+ */
+ @PatchMapping(value = "/updateEnrollmentCount", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> setEnrollmentCount(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode,
+ @RequestParam("count") int count) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
requestedCourse.setEnrolledStudentCount(count);
- return new ResponseEntity<>("Attributed was updated successfully.", HttpStatus.OK);
+ return new ResponseEntity<>(requestedCourse.toString(), HttpStatus.OK);
} else {
return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
@@ -407,28 +432,30 @@ public ResponseEntity> setEnrollmentCount(@RequestParam(value = "deptCode") St
* This method handles PATCH requests to change the time of a course identified by
* department code and course code.If the course exists, its time is updated to the provided time.
*
- * @param deptCode the code of the department containing the course
- * @param courseCode the code of the course to change the time for
- * @param time the new time for the course
+ * @param deptCode the code of the department containing the course
+ * @param courseCode the code of the course to change the time for
+ * @param time the new time for the course
*
- * @return a ResponseEntity with a success message if the operation is
- * successful, or an error message if the course is not found
+ * @return a ResponseEntity with a success message if the operation is
+ * successful, or an error message if the course is not found
*/
- @PatchMapping(value = "/changeCourseTime", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> changeCourseTime(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode, @RequestParam(value = "time") String time) {
+ @PatchMapping(value = "/updateCourseTime", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> changeCourseTime(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode,
+ @RequestParam("time") String time) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
requestedCourse.reassignTime(time);
- return new ResponseEntity<>("Attributed was updated successfully.", HttpStatus.OK);
+ return new ResponseEntity<>(requestedCourse.toString(), HttpStatus.OK);
} else {
return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
@@ -443,28 +470,30 @@ public ResponseEntity> changeCourseTime(@RequestParam(value = "deptCode") Stri
* department code and course code. If the course exists, its instructor is updated to the
* provided instructor.
*
- * @param deptCode the code of the department containing the course
- * @param courseCode the code of the course to change the instructor for
- * @param teacher the new instructor for the course
+ * @param deptCode the code of the department containing the course
+ * @param courseCode the code of the course to change the instructor for
+ * @param teacher the new instructor for the course
*
- * @return a ResponseEntity with a success message if the operation is
- * successful, or an error message if the course is not found
+ * @return a ResponseEntity with a success message if the operation is
+ * successful, or an error message if the course is not found
*/
- @PatchMapping(value = "/changeCourseTeacher", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> changeCourseTeacher(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode, @RequestParam(value = "teacher") String teacher) {
+ @PatchMapping(value = "/updateCourseTeacher", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> changeCourseTeacher(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode,
+ @RequestParam("teacher") String teacher) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
requestedCourse.reassignInstructor(teacher);
- return new ResponseEntity<>("Attributed was updated successfully.", HttpStatus.OK);
+ return new ResponseEntity<>(requestedCourse.toString(), HttpStatus.OK);
} else {
return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
@@ -473,22 +502,36 @@ public ResponseEntity> changeCourseTeacher(@RequestParam(value = "deptCode") S
}
}
-
- @PatchMapping(value = "/changeCourseLocation", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity> changeCourseLocation(@RequestParam(value = "deptCode") String deptCode, @RequestParam(value = "courseCode") int courseCode, @RequestParam(value = "location") String location) {
+ /**
+ * Endpoint for changing the location of a course.
+ * This method handles PATCH requests to change the location of a course identified by
+ * department code and course code. If the course exists, its location is updated to the
+ * provided location.
+ *
+ * @param deptCode the code of the department containing the course
+ * @param courseCode the code of the course to change the location for
+ * @param location the new location for the course
+ * successful, or an error message if the course is not found
+ *
+ * @return a ResponseEntity with a success message if the operation is
+ */
+ @PatchMapping(value = "/updateCourseLocation", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity> changeCourseLocation(@RequestParam("deptCode") String deptCode,
+ @RequestParam("courseCode") int courseCode,
+ @RequestParam("location") String location) {
try {
boolean doesCourseExists;
doesCourseExists = retrieveCourse(deptCode, courseCode).getStatusCode() == HttpStatus.OK;
if (doesCourseExists) {
- HashMap departmentMapping;
+ Map departmentMapping;
departmentMapping = IndividualProjectApplication.myFileDatabase.getDepartmentMapping();
- HashMap coursesMapping;
+ Map coursesMapping;
coursesMapping = departmentMapping.get(deptCode).getCourseSelection();
Course requestedCourse = coursesMapping.get(Integer.toString(courseCode));
requestedCourse.reassignLocation(location);
- return new ResponseEntity<>("Attributed was updated successfully.", HttpStatus.OK);
+ return new ResponseEntity<>(requestedCourse.toString(), HttpStatus.OK);
} else {
return new ResponseEntity<>("Course Not Found", HttpStatus.NOT_FOUND);
}
@@ -503,4 +546,4 @@ private ResponseEntity> handleException(Exception e) {
}
-}
\ No newline at end of file
+}
diff --git a/IndividualProject/src/pmd-report.txt b/IndividualProject/src/pmd-report.txt
new file mode 100644
index 00000000..a53a1546
--- /dev/null
+++ b/IndividualProject/src/pmd-report.txt
@@ -0,0 +1,71 @@
+main/java/dev/coms4156/project/individualproject/Course.java:108: MissingOverride: The method 'toString()' is missing an @Override annotation.
+main/java/dev/coms4156/project/individualproject/Department.java:24: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/Department.java:55: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/Department.java:112: MissingOverride: The method 'toString()' is missing an @Override annotation.
+main/java/dev/coms4156/project/individualproject/Department.java:125: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java:55: LiteralsFirstInComparisons: Position literals first in String comparisons
+main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java:90: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/IndividualProjectApplication.java:100: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/MyFileDatabase.java:37: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/MyFileDatabase.java:46: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/MyFileDatabase.java:49: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/MyFileDatabase.java:50: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/MyFileDatabase.java:67: ReturnEmptyCollectionRatherThanNull: Return an empty collection rather than null.
+main/java/dev/coms4156/project/individualproject/MyFileDatabase.java:89: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/MyFileDatabase.java:113: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:45: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:47: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:51: UseLocaleWithCaseConversions: When doing a String.toLowerCase()/toUpperCase() call, use a Locale
+main/java/dev/coms4156/project/individualproject/RouteController.java:75: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:76: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:78: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:80: UseLocaleWithCaseConversions: When doing a String.toLowerCase()/toUpperCase() call, use a Locale
+main/java/dev/coms4156/project/individualproject/RouteController.java:82: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:110: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:111: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:117: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:119: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:144: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:148: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:171: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:175: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:200: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:201: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:207: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:209: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:237: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:238: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:245: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:247: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:276: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:277: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:283: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:285: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:309: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:313: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:336: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:340: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:364: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:365: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:371: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:373: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:404: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:405: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:406: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:412: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:414: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:441: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:442: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:443: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:449: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:451: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:479: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:480: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:481: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:487: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:489: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:517: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:518: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:519: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
+main/java/dev/coms4156/project/individualproject/RouteController.java:525: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+main/java/dev/coms4156/project/individualproject/RouteController.java:527: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
diff --git a/IndividualProject/src/pmd-report2.txt b/IndividualProject/src/pmd-report2.txt
new file mode 100644
index 00000000..1057883e
--- /dev/null
+++ b/IndividualProject/src/pmd-report2.txt
@@ -0,0 +1 @@
+main/java/dev/coms4156/project/individualproject/RouteController.java:482: UnnecessaryAnnotationValueElement: Avoid the use of value in annotations when its the only element
diff --git a/IndividualProject/src/pmd-report3.txt b/IndividualProject/src/pmd-report3.txt
new file mode 100644
index 00000000..6d885517
--- /dev/null
+++ b/IndividualProject/src/pmd-report3.txt
@@ -0,0 +1,5 @@
+test/java/dev/coms4156/project/individualproject/DepartmentUnitTests.java:23: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:29: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:65: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:81: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:85: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
diff --git a/IndividualProject/src/pmd-report4.txt b/IndividualProject/src/pmd-report4.txt
new file mode 100644
index 00000000..e4ca44a3
--- /dev/null
+++ b/IndividualProject/src/pmd-report4.txt
@@ -0,0 +1,5 @@
+test/java/dev/coms4156/project/individualproject/DepartmentUnitTests.java:20: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:25: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:56: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:71: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
+test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java:76: LooseCoupling: Avoid using implementation types like 'HashMap'; use the interface instead
diff --git a/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java
index 4edd00f9..bf7cffbf 100644
--- a/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java
+++ b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/CourseUnitTests.java
@@ -1,28 +1,143 @@
package dev.coms4156.project.individualproject;
-import org.junit.jupiter.api.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
-import static org.junit.jupiter.api.Assertions.*;
-
+/**
+ * Unit tests for the Course class.
+ */
@SpringBootTest
@ContextConfiguration
public class CourseUnitTests {
- @BeforeAll
- public static void setupCourseForTesting() {
- testCourse = new Course("Griffin Newbold", "417 IAB", "11:40-12:55", 250);
- }
+ /** The test course instance used for testing. */
+ public static Course testCourse;
+ /**
+ * Sets up a Course object for testing.
+ * This method is run once before all tests.
+ */
+ @BeforeEach
+ public void setupCourseForTesting() {
+ testCourse = new Course("G N", "417 IAB", "11:40-12:55", 250);
+ }
+ /**
+ * Tests the toString method of the Course class.
+ * This test checks if the toString method returns the correct string
+ * representation of the course.
+ */
@Test
public void toStringTest() {
- String expectedResult = "\nInstructor: Griffin Newbold; Location: 417 IAB; Time: 11:40-12:55";
+ String expectedResult =
+ "\nInstructor: G N; Location: 417 IAB; Time: 11:40-12:55; Capacity: 250; Enrollment: 500";
assertEquals(expectedResult, testCourse.toString());
}
- /** The test course instance used for testing. */
- public static Course testCourse;
-}
+ @Test
+ public void enrollStudentTest() {
+ int initialCount = testCourse.getEnrolledStudentCount();
+ testCourse.enrollStudent();
+ assertEquals(initialCount + 1, testCourse.getEnrolledStudentCount());
+ }
+
+ /**
+ * Tests the dropStudent method by dropping a student from the course.
+ * Checks that the new student count decreased by one.
+ */
+ @Test
+ public void dropStudentTest() {
+ int initialCount = testCourse.getEnrolledStudentCount();
+ testCourse.dropStudent();
+ assertEquals(initialCount - 1, testCourse.getEnrolledStudentCount());
+ }
+
+ /**
+ * Tests the getCourseLocation method by checking if it returns the correct course location.
+ */
+ @Test
+ public void getCourseLocationTest() {
+ assertEquals("417 IAB",
+ testCourse.getCourseLocation());
+ }
+
+ /**
+ * Tests the getInstructorName method by checking the instructor name matches initialized value.
+ */
+ @Test
+ public void getInstructorNameTest() {
+ assertEquals("G N",
+ testCourse.getInstructorName());
+ }
+
+ /**
+ * Tests the getCourseTimeSlot method to verify it returns the correct course time slot.
+ */
+ @Test
+ public void getCourseTimeSlotTest() {
+ assertEquals("11:40-12:55", testCourse.getCourseTimeSlot());
+ }
+
+ /**
+ * Tests the reassignInstructor method to ensure the instructor name can be updated.
+ */
+ @Test
+ public void reassignInstructorTest() {
+ String newInsName = "New Instructor";
+ testCourse.reassignInstructor(newInsName);
+ assertEquals(newInsName, testCourse.getInstructorName());
+ }
+
+ /**
+ * Tests the reassignLocation method to ensure the course location can be updated.
+ */
+ @Test
+ public void reassignLocationTest() {
+ String newLocation = "New Location";
+ testCourse.reassignLocation(newLocation);
+ String currLocation = testCourse.getCourseLocation();
+ assertEquals(newLocation, currLocation);
+ }
+
+ /**
+ * Tests the reassignTime method to ensure the course time can be updated.
+ */
+ @Test
+ public void reassignTimeTest() {
+ testCourse.reassignTime("10:00-11:15");
+ assertEquals("10:00-11:15", testCourse.getCourseTimeSlot());
+ }
+
+ /**
+ * Tests the setEnrolledStudentCount method to ensure the student count can be updated.
+ */
+ @Test
+ public void setEnrolledStudentCountTest() {
+ testCourse.setEnrolledStudentCount(100);
+ assertEquals(100, testCourse.getEnrolledStudentCount());
+
+ // Test negative values
+ testCourse.setEnrolledStudentCount(-100);
+ assertEquals(-100, testCourse.getEnrolledStudentCount());
+
+ }
+
+ /**
+ * Tests the isCourseFull method to verify it correctly checks if the course is full.
+ */
+ @Test
+ public void isCourseFullTest() {
+ testCourse.setEnrolledStudentCount(250); // Match the capacity
+ assertFalse(testCourse.isCourseFull());
+
+ testCourse.setEnrolledStudentCount(260); // Set count over the max capacity
+ assertTrue(testCourse.isCourseFull());
+ }
+}
diff --git a/IndividualProject/src/test/java/dev/coms4156/project/individualproject/DepartmentUnitTests.java b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/DepartmentUnitTests.java
new file mode 100644
index 00000000..5c398cce
--- /dev/null
+++ b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/DepartmentUnitTests.java
@@ -0,0 +1,95 @@
+package dev.coms4156.project.individualproject;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+
+/**
+ * Unit tests for the Department class.
+ */
+@SpringBootTest
+@ContextConfiguration
+public class DepartmentUnitTests {
+
+ /** The test department instance used for testing. */
+ public static Department testDepartment;
+ public static Map testCourses;
+
+ /**
+ * Sets up a Department object for testing.
+ * Runs once before each test is conducted.
+ */
+ @BeforeEach
+ public void setupForTesting() {
+ testCourses = new HashMap<>();
+ testCourses.put("1004", new Course("Adam Cannon", "417 IAB", "11:40-12:55", 400));
+ testDepartment = new Department("COMS", testCourses,
+ "Luca Carloni", 2700);
+ }
+
+ /**
+ * Tests the getNumberOfMajors method to ensure it returns the correct number of majors.
+ */
+ @Test
+ public void getNumberOfMajorsTest() {
+ assertEquals(2700, testDepartment.getNumberOfMajors());
+ }
+
+ /**
+ * Tests the getDepartmentChair method and verifies that it returns the correct department chair.
+ */
+ @Test
+ public void getDepartmentChairTest() {
+ assertEquals("Luca Carloni", testDepartment.getDepartmentChair());
+ }
+
+ /**
+ * Tests that getCourseSelection method returns the appropriate course selection.
+ */
+ @Test
+ public void getCourseSelectionTest() {
+ assertEquals(testCourses, testDepartment.getCourseSelection());
+ }
+
+ /**
+ * Tests the createCourse method by creating a new course and adding it to the department.
+ * Tests that all the attributes are correctly set.
+ */
+ @Test
+ public void createCourseTest() {
+ testDepartment.createCourse("3157", "Jae Lee", "417 IAB", "4:10-5:25", 400);
+ Course createdCourse = testDepartment.getCourseSelection().get("3157");
+
+ // Verify that the course was successfully created and added
+ assertEquals("Jae Lee", createdCourse.getInstructorName());
+ assertEquals("417 IAB", createdCourse.getCourseLocation());
+ assertEquals("4:10-5:25", createdCourse.getCourseTimeSlot());
+ assertEquals(400, createdCourse.getEnrollmentCapacity());
+ }
+
+ /**
+ * Tests the addPersonToMajor method by incrementing the number of majors.
+ */
+ @Test
+ public void addPersonToMajorTest() {
+ int initialCount = testDepartment.getNumberOfMajors();
+ testDepartment.addPersonToMajor();
+ assertEquals(initialCount + 1, testDepartment.getNumberOfMajors());
+ }
+
+ /**
+ * Tests the dropPersonFromMajor method by decrementing the number of majors.
+ * The updated value is then verified.
+ */
+ @Test
+ public void dropPersonFromMajorTest() {
+ int initialCount = testDepartment.getNumberOfMajors();
+ testDepartment.dropPersonFromMajor();
+ assertEquals(initialCount - 1, testDepartment.getNumberOfMajors());
+ }
+}
diff --git a/IndividualProject/src/test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java
new file mode 100644
index 00000000..71523004
--- /dev/null
+++ b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/MyFileDatabaseUnitTests.java
@@ -0,0 +1,140 @@
+package dev.coms4156.project.individualproject;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+
+
+/**
+ * Unit tests for the MyFileDatabase class.
+ */
+@SpringBootTest
+@ContextConfiguration
+public class MyFileDatabaseUnitTests {
+
+ private MyFileDatabase testDatabase;
+ private HashMap testMapping;
+
+ /**
+ * Sets up the test database before each test.
+ */
+ @BeforeEach
+ public void setupDatabaseForTesting() {
+ testMapping = new HashMap<>();
+
+ Department testDepartment = new Department("COMS", new HashMap<>(), "Luca Carloni", 2700);
+ testMapping.put("COMS", testDepartment);
+
+ testDatabase = new MyFileDatabase(1, "./testData.txt");
+ testDatabase.setMapping(testMapping);
+ }
+
+ /**
+ * Teardown method to wipe the test file after each test, if it exists.
+ */
+ @AfterEach
+ public void tearDown() {
+ File file = new File("./testData.txt");
+ if (file.exists()) {
+ assertTrue(file.delete());
+ }
+ }
+
+ /**
+ * Test for setMapping method.
+ * Checks that the department mapping is correctly set.
+ */
+ @Test
+ public void setMappingTest() {
+ HashMap newMapping = new HashMap<>();
+ Department newDepartment = new Department("MATH", new HashMap<>(),
+ "Joan Smith", 500);
+ newMapping.put("MATH", newDepartment);
+
+ testDatabase.setMapping(newMapping);
+ assertEquals(newMapping, testDatabase.getDepartmentMapping());
+ }
+
+ /**
+ * Test for deSerializeObjectFromFile method.
+ * This test checks inserts data into the Database
+ * It then checks that the data is deserialized from file correctly + checks expected values.
+ */
+ @Test
+ public void deSerializeObjectFromFileTest() throws IOException {
+ HashMap courses = new HashMap<>();
+ courses.put("1004", new Course("Adam Cannon", "417 IAB", "11:40-12:55", 400));
+
+ Department testDepartment = new Department("COMS", courses, "Luca Carloni", 2700);
+ HashMap expectedMapping = new HashMap<>();
+ expectedMapping.put("COMS", testDepartment);
+
+ try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("./testData.txt"))) {
+ out.writeObject(expectedMapping);
+ }
+
+ Map deserializedData = testDatabase.deSerializeObjectFromFile();
+
+ assertTrue(deserializedData.containsKey("COMS"));
+
+ Department deserializedDepartment = deserializedData.get("COMS");
+
+ assertEquals("Luca Carloni", deserializedDepartment.getDepartmentChair());
+ assertEquals(2700, deserializedDepartment.getNumberOfMajors());
+
+ assertTrue(deserializedDepartment.getCourseSelection().containsKey("1004"));
+
+ Course deserializedCourse = deserializedDepartment.getCourseSelection().get("1004");
+ assertNotNull(deserializedCourse);
+
+ // Check course attributes
+ assertEquals("Adam Cannon", deserializedCourse.getInstructorName());
+ assertEquals("417 IAB", deserializedCourse.getCourseLocation());
+ assertEquals("11:40-12:55", deserializedCourse.getCourseTimeSlot());
+ assertEquals(400, deserializedCourse.getEnrollmentCapacity());
+ }
+
+
+ /**
+ * Test for saveContentsToFile method.
+ */
+ @Test
+ public void saveContentsToFileTest() throws IOException {
+ // Write to test file
+ testDatabase.saveContentsToFile();
+
+ // Ensure the file was created and isn't empty
+ File file = new File("./testData.txt");
+ assertTrue(file.exists());
+ assertTrue(file.length() > 0);
+ }
+
+ /**
+ * Test for getDepartmentMapping method.
+ */
+ @Test
+ public void getDepartmentMappingTest() {
+ assertEquals(testMapping, testDatabase.getDepartmentMapping());
+ }
+
+ /**
+ * Test for toString method.
+ */
+ @Test
+ public void toStringTest() {
+ String dbString = testDatabase.toString();
+ assertTrue(dbString.contains("COMS"));
+ }
+}
diff --git a/IndividualProject/src/test/java/dev/coms4156/project/individualproject/RouteControllerUnitTests.java b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/RouteControllerUnitTests.java
new file mode 100644
index 00000000..13d9fe6f
--- /dev/null
+++ b/IndividualProject/src/test/java/dev/coms4156/project/individualproject/RouteControllerUnitTests.java
@@ -0,0 +1,398 @@
+package dev.coms4156.project.individualproject;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * These are Unit tests for the RouteController class.
+ * The class initializes the application using the setup param.
+ * This is done to trigger the resetData script to populate the test database.
+ */
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, args = {"setup"})
+public class RouteControllerUnitTests {
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+
+ /**
+ * Sets up application object for testing.
+ * This method is run once before all tests.
+ */
+ @BeforeAll
+ public static void setupApplicationForTesting() {
+ // Override the database with test data
+ IndividualProjectApplication.overrideDatabase(new MyFileDatabase(1,
+ "./testData.txt"));
+ }
+
+ /**
+ * Test for the home route ("/index").
+ */
+ @Test
+ public void indexTest() {
+ String url = "http://localhost:" + port + "/index";
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals("""
+ Welcome, in order to make an API call direct your browser or Postman to an endpoint\s
+
+ This can be done using the following format:\s
+
+ http:127.0.0.1:8080/endpoint?arg=value""", response.getBody());
+ }
+
+ /**
+ * Test for the retrieve course route ("/retrieveCourse").
+ * The course should not exist.
+ */
+ @Test
+ public void retrieveCourseNotFoundTest() {
+ String url = "http://localhost:" + port + "/retrieveCourse?deptCode=COMS&courseCode=0000";
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(response.getStatusCode(), HttpStatus.NOT_FOUND);
+ }
+
+ /**
+ * Test for the retrieve department route ("/retrieveDept").
+ * The department should not exist.
+ */
+ @Test
+ public void retrieveDepartmentNotFoundTest() {
+ String url = "http://localhost:" + port + "/retrieveDept?deptCode=INVALID";
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
+ }
+
+ /**
+ * Test for ("/findCourseLocation").
+ */
+ @Test
+ public void findCourseLocationTest() {
+ String deptCode = "COMS";
+ String courseCode = "1004";
+ String url = "http://localhost:" + port + "/findCourseLocation?deptCode="
+ + deptCode + "&courseCode=" + courseCode;
+
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ assertTrue(response.getBody().contains("417 IAB"));
+ }
+
+ /**
+ * Test for ("/findCourseInstructor").
+ */
+ @Test
+ public void findCourseInstructorTest() {
+ String deptCode = "COMS";
+ String courseCode = "1004";
+ String url = "http://localhost:" + port
+ + "/findCourseInstructor?deptCode=" + deptCode
+ + "&courseCode=" + courseCode;
+
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ assertTrue(response.getBody().contains("Adam Cannon"));
+ }
+
+ /**
+ * Test for ("/findCourseTime").
+ */
+ @Test
+ public void findCourseTimeTest() {
+ String deptCode = "COMS";
+ String courseCode = "1004";
+ String url = "http://localhost:" + port
+ + "/findCourseTime?deptCode=" + deptCode + "&courseCode=" + courseCode;
+
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ assertTrue(response.getBody().contains("11:40-12:55"));
+ }
+
+ /**
+ * Test for ("/retrieveDept").
+ */
+ @Test
+ public void retrieveAllDepartmentsTest() {
+ String[] departments = {"COMS", "ECON", "IEOR", "CHEM", "PHYS", "ELEN", "PSYC"};
+
+ for (String deptCode : departments) {
+ String url = "http://localhost:" + port + "/retrieveDept?deptCode=" + deptCode;
+
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ }
+ }
+
+
+ /**
+ * Test for ("/retrieveCourse").
+ * This tests that each course exists, based on the data populated in the application file.
+ */
+ @Test
+ public void retrieveAllCoursesTest() {
+ Map departmentCourses = new HashMap<>();
+
+ departmentCourses.put("COMS",
+ new String[]{"1004", "3134", "3157", "3203", "3261", "3251", "3827", "4156"});
+
+ departmentCourses.put("ECON",
+ new String[]{"1105", "2257", "3211", "3213", "3412", "4415", "4710", "4840"});
+
+ departmentCourses.put("IEOR",
+ new String[]{"2500", "3404", "3658", "4102", "4106", "4405", "4511", "4540"});
+
+ departmentCourses.put("CHEM",
+ new String[]{"1403", "1500", "2045", "2444", "2494", "3080", "4071", "4102"});
+
+ departmentCourses.put("PHYS",
+ new String[]{"1001", "1201", "1602", "2802", "3008", "4003", "4018", "4040"});
+
+ departmentCourses.put("ELEN",
+ new String[]{"1201", "3082", "3331", "3401", "3701", "4510", "4702", "4830"});
+
+ departmentCourses.put("PSYC",
+ new String[]{"1001", "1610", "2235", "2620", "3212", "3445", "4236", "4493"});
+
+ for (Map.Entry department : departmentCourses.entrySet()) {
+ String deptCode = department.getKey();
+ String[] associatedCourses = department.getValue();
+
+ for (String courseCode : associatedCourses) {
+ String url = "http://localhost:"
+ + port + "/retrieveCourse?deptCode="
+ + deptCode + "&courseCode=" + courseCode;
+
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ }
+ }
+ }
+
+
+
+
+ /**
+ * Test for ("/isCourseFull").
+ * Case where course is full.
+ */
+ @Test
+ public void courseIsFullTest() {
+ String updateEnrollUrl = "http://localhost:" + port
+ + "/updateEnrollmentCount?deptCode=COMS"
+ + "&courseCode=1004&count=100000";
+ restTemplate.patchForObject(updateEnrollUrl, null, String.class);
+ String url = "http://localhost:" + port + "/isCourseFull?deptCode=COMS&courseCode=1004";
+ ResponseEntity response = restTemplate.getForEntity(url, Boolean.class);
+ assertEquals(true, response.getBody());
+ }
+
+
+
+ /**
+ * Test for ("/isCourseFull").
+ * Case where the course is not full.
+ */
+ @Test
+ public void courseIsNotFullTest() {
+ String url = "http://localhost:" + port + "/isCourseFull?deptCode=COMS&courseCode=1004";
+ ResponseEntity response = restTemplate.getForEntity(url, Boolean.class);
+
+ assertEquals(false, response.getBody());
+ }
+
+ /**
+ * Test for ("/getMajorCountFromDept").
+ */
+ @Test
+ public void getMajorCountFromDeptTest() {
+ String url = "http://localhost:" + port + "/getMajorCountFromDept?deptCode=COMS";
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ }
+
+ /**
+ * Test for ("/idDeptChair").
+ */
+ @Test
+ public void identifyDeptChairTest() {
+ String deptCode = "COMS";
+ String url = "http://localhost:" + port + "/idDeptChair?deptCode=" + deptCode;
+
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ assertTrue(response.getBody().contains("Luca Carloni"));
+ }
+
+ /**
+ * Test for identifying the department chair ("/idDeptChair").
+ * Case when department is not found.
+ */
+ @Test
+ public void identifyDeptChairNotFoundTest() {
+ String deptCode = "INVALID";
+ String url = "http://localhost:" + port + "/idDeptChair?deptCode=" + deptCode;
+
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
+ assertTrue(response.getBody().contains("Department Not Found"));
+ }
+
+ /**
+ * Test for ("/removeMajorFromDept").
+ */
+ @Test
+ public void removeMajorFromDeptTest() {
+ String deptCode = "COMS";
+ String url = "http://localhost:" + port + "/removeMajorFromDept?deptCode=" + deptCode;
+
+ String response = restTemplate.patchForObject(url, null, String.class);
+
+ assertTrue(response.contains("Attribute was updated or is at minimum"));
+ }
+
+ /**
+ * Test for ("/removeMajorFromDept").
+ * Case when department is not found.
+ */
+ @Test
+ public void removeMajorFromDeptNotFoundTest() {
+ String deptCode = "INVALID";
+ String url = "http://localhost:" + port + "/removeMajorFromDept?deptCode=" + deptCode;
+
+ String response = restTemplate.patchForObject(url, null, String.class);
+
+ assertTrue(response.contains("Department Not Found"));
+ }
+
+ /**
+ * Test for ("/dropStudentFromCourse").
+ */
+ @Test
+ public void dropStudentFromCourseTest() {
+ String deptCode = "COMS";
+ int courseCode = 1004;
+ String url = "http://localhost:" + port + "/dropStudentFromCourse?deptCode="
+ + deptCode + "&courseCode=" + courseCode;
+
+ String response = restTemplate.patchForObject(url, null, String.class);
+ assertTrue(response.contains("Student has been dropped."));
+ }
+
+ /**
+ * Test for dropping a student from a course ("/dropStudentFromCourse").
+ * Case when the course is not found.
+ */
+ @Test
+ public void dropStudentFromCourseNotFoundTest() {
+ String deptCode = "COMS";
+ int courseCode = 9999; // Invalid course code
+ String url = "http://localhost:" + port + "/dropStudentFromCourse?deptCode="
+ + deptCode + "&courseCode=" + courseCode;
+
+ String response = restTemplate.patchForObject(url, null, String.class);
+
+ assertTrue(response.contains("Course Not Found"));
+ }
+
+ /**
+ * Test for ("/addMajorToDept").
+ */
+ @Test
+ public void addMajorToDeptTest() {
+ String url = "http://localhost:" + port + "/addMajorToDept?deptCode=COMS";
+ String response = restTemplate.patchForObject(url, null, String.class);
+ assertTrue(response.contains("Attribute was updated successfully"));
+ }
+
+ /**
+ * Test for ("/setEnrollment").
+ */
+ @Test
+ public void changeCourseEnrollment() {
+ String deptCode = "COMS";
+ String courseCode = "1004";
+ String count = "100000";
+ String updateEnrollUrl = "http://localhost:" + port + "/updateEnrollmentCount" + "?deptCode="
+ + deptCode + "&courseCode=" + courseCode + "&count=" + count;
+ String response = restTemplate.patchForObject(updateEnrollUrl, null, String.class);
+
+ assertTrue(response.contains(count));
+ }
+
+ /**
+ * Test for ("/updateCourseTime").
+ */
+ @Test
+ public void changeCourseTimeTest() {
+ String deptCode = "COMS";
+ String courseCode = "1004";
+ String newTime = "10:10-11:25";
+ String changeTimeUrl = "http://localhost:" + port + "/updateCourseTime"
+ + "?deptCode=" + deptCode + "&courseCode=" + courseCode
+ + "&time=" + newTime;
+
+ String response = restTemplate.patchForObject(changeTimeUrl, null, String.class);
+
+ assertTrue(response.contains(newTime));
+ }
+
+ /**
+ * Test for ("/updateCourseTeacher").
+ */
+ @Test
+ public void changeCourseInstructorTest() {
+ String deptCode = "COMS";
+ String courseCode = "1004";
+ String newInstructor = "New Instructor";
+ String changeInstructorUrl = "http://localhost:" + port + "/updateCourseTeacher"
+ + "?deptCode=" + deptCode + "&courseCode=" + courseCode
+ + "&teacher=" + newInstructor;
+
+ String response = restTemplate.patchForObject(changeInstructorUrl, null, String.class);
+
+ assertTrue(response.contains(newInstructor));
+ }
+
+ /**
+ * Test for ("/updateCourseLocation").
+ */
+ @Test
+ public void changeCourseLocationTest() {
+ String deptCode = "COMS";
+ String courseCode = "1004";
+ String newLocation = "New Location";
+ String changeLocationUrl = "http://localhost:" + port + "/updateCourseLocation"
+ + "?deptCode=" + deptCode + "&courseCode=" + courseCode
+ + "&location=" + newLocation;
+
+ String response = restTemplate.patchForObject(changeLocationUrl, null, String.class);
+
+ assertTrue(response.contains(newLocation));
+ }
+}
diff --git a/README.md b/README.md
index 93e4ba9b..0608cf4f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,9 @@
# Welcome Students of 4156
Please follow the assignment specifications on Courseworks when completing this project.
+
+Follow these steps to run PMD static code analysis:
+1. Navigate to the src folder
+2. Enter in the following command:
+pmd check -f text -R rulesets/java/quickstart.xml -r pmd-report.txt -d main,test
+3. The output of the analysis will be viewable in the specified output file
diff --git a/data.txt b/data.txt
new file mode 100644
index 00000000..52e564ee
Binary files /dev/null and b/data.txt differ