diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..97228b2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,16 @@
+.gradle
+/build/
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+# Cache of project
+.gradletasknamecache
+
+# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
+# gradle/wrapper/gradle-wrapper.properties
+
+.idea
diff --git a/.gradle/4.10.3/fileChanges/last-build.bin b/.gradle/4.10.3/fileChanges/last-build.bin
deleted file mode 100644
index f76dd23..0000000
Binary files a/.gradle/4.10.3/fileChanges/last-build.bin and /dev/null differ
diff --git a/.gradle/4.10.3/fileContent/fileContent.lock b/.gradle/4.10.3/fileContent/fileContent.lock
deleted file mode 100644
index 6de39bb..0000000
Binary files a/.gradle/4.10.3/fileContent/fileContent.lock and /dev/null differ
diff --git a/.gradle/4.10.3/fileHashes/fileHashes.bin b/.gradle/4.10.3/fileHashes/fileHashes.bin
deleted file mode 100644
index f7b7aae..0000000
Binary files a/.gradle/4.10.3/fileHashes/fileHashes.bin and /dev/null differ
diff --git a/.gradle/4.10.3/fileHashes/fileHashes.lock b/.gradle/4.10.3/fileHashes/fileHashes.lock
deleted file mode 100644
index d8ebc19..0000000
Binary files a/.gradle/4.10.3/fileHashes/fileHashes.lock and /dev/null differ
diff --git a/.gradle/4.10.3/gc.properties b/.gradle/4.10.3/gc.properties
deleted file mode 100644
index e69de29..0000000
diff --git a/.gradle/4.10.3/javaCompile/classAnalysis.bin b/.gradle/4.10.3/javaCompile/classAnalysis.bin
deleted file mode 100644
index 8fcaf67..0000000
Binary files a/.gradle/4.10.3/javaCompile/classAnalysis.bin and /dev/null differ
diff --git a/.gradle/4.10.3/javaCompile/jarAnalysis.bin b/.gradle/4.10.3/javaCompile/jarAnalysis.bin
deleted file mode 100644
index ba43ef0..0000000
Binary files a/.gradle/4.10.3/javaCompile/jarAnalysis.bin and /dev/null differ
diff --git a/.gradle/4.10.3/javaCompile/javaCompile.lock b/.gradle/4.10.3/javaCompile/javaCompile.lock
deleted file mode 100644
index 8b7a46b..0000000
Binary files a/.gradle/4.10.3/javaCompile/javaCompile.lock and /dev/null differ
diff --git a/.gradle/4.10.3/javaCompile/taskHistory.bin b/.gradle/4.10.3/javaCompile/taskHistory.bin
deleted file mode 100644
index 1446888..0000000
Binary files a/.gradle/4.10.3/javaCompile/taskHistory.bin and /dev/null differ
diff --git a/.gradle/4.10.3/taskHistory/taskHistory.bin b/.gradle/4.10.3/taskHistory/taskHistory.bin
deleted file mode 100644
index 8b00a15..0000000
Binary files a/.gradle/4.10.3/taskHistory/taskHistory.bin and /dev/null differ
diff --git a/.gradle/4.10.3/taskHistory/taskHistory.lock b/.gradle/4.10.3/taskHistory/taskHistory.lock
deleted file mode 100644
index ba4509c..0000000
Binary files a/.gradle/4.10.3/taskHistory/taskHistory.lock and /dev/null differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
deleted file mode 100644
index bc5e0b5..0000000
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and /dev/null differ
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
deleted file mode 100644
index a17aace..0000000
--- a/.gradle/buildOutputCleanup/cache.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-#Tue Nov 05 17:22:42 UTC 2019
-gradle.version=4.10.3
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
deleted file mode 100644
index 905d7a9..0000000
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and /dev/null differ
diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties
deleted file mode 100644
index e69de29..0000000
diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$
deleted file mode 100644
index 79be354..0000000
--- a/.idea/$PRODUCT_WORKSPACE_FILE$
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
- 11
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 5c98b42..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Default ignored files
-/workspace.xml
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 3ba0e33..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 25d34a4..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6e5cf89
--- /dev/null
+++ b/README.md
@@ -0,0 +1,22 @@
+## TURNTABL CLIENT MANAGEMENT SYSTEM
+This is a simple java command line application built at turntabl by desk1 during the TLC 2019.
+The build tool used is gradle.
+
+### Installing and running the application
+1. Ensure that `gradlew` is installed your your local machine.
+2. Clone the project.
+3. At the project root, run the executable file `run`.
+This should run the *tests* and *build* the project if it has not been built already and finally, run the application.
+
+### Some key algorithms
+- Levenshtein algorithm
+
+### Contributors
+- [Christiana Asare](github.com/christianaasare)
+- [Francis Billa](github.com/FrancisBilla)
+- [Bill Ali](github.com/bill-n)
+- [Dennis Effa Amponsah](github.com/effaamponsah)
+
+
+### Contributing
+This project is not yet opened for contributions.
diff --git a/build.gradle b/build.gradle
index 85826d8..126ff67 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
plugins {
id 'java'
+ id 'application'
}
group 'turntabl'
@@ -13,4 +14,23 @@ repositories {
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
+ compile group: 'com.h2database', name: 'h2', version: '1.3.148'
}
+
+application {
+ mainClassName = 'io.turntabl.tcms.ClientManagementSystem'
+}
+
+task create(type: Copy) {
+ from './clients.csv'
+ into 'build/scripts'
+}
+tasks.startScripts {
+ doLast {
+ def scriptFile = file "${outputDir}/${applicationName}"
+ scriptFile.text = scriptFile.text.replace('CLASSPATH=$APP_HOME/lib', 'CLASSPATH=$APP_HOME/libs')
+ }
+}
+application {
+ mainClassName = 'io.turntabl.tcms.ClientManagementSystem'
+}
\ No newline at end of file
diff --git a/build/classes/java/main/io/turntabl/Numbers.class b/build/classes/java/main/io/turntabl/Numbers.class
deleted file mode 100644
index 87e82d4..0000000
Binary files a/build/classes/java/main/io/turntabl/Numbers.class and /dev/null differ
diff --git a/build/classes/java/main/io/turntabl/tcms/Numbers.class b/build/classes/java/main/io/turntabl/tcms/Numbers.class
deleted file mode 100644
index b0e4631..0000000
Binary files a/build/classes/java/main/io/turntabl/tcms/Numbers.class and /dev/null differ
diff --git a/build/classes/java/test/io/turntabl/NumbersTest.class b/build/classes/java/test/io/turntabl/NumbersTest.class
deleted file mode 100644
index e010fef..0000000
Binary files a/build/classes/java/test/io/turntabl/NumbersTest.class and /dev/null differ
diff --git a/build/classes/java/test/io/turntabl/tcms/NumbersTest.class b/build/classes/java/test/io/turntabl/tcms/NumbersTest.class
deleted file mode 100644
index 6633371..0000000
Binary files a/build/classes/java/test/io/turntabl/tcms/NumbersTest.class and /dev/null differ
diff --git a/build/reports/tests/test/classes/io.turntabl.tcms.NumbersTest.html b/build/reports/tests/test/classes/io.turntabl.tcms.NumbersTest.html
deleted file mode 100644
index 4fdab6c..0000000
--- a/build/reports/tests/test/classes/io.turntabl.tcms.NumbersTest.html
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
-Test results - Class io.turntabl.tcms.NumbersTest
-
-
-
-
-
-
-
Class io.turntabl.tcms.NumbersTest
-
-
-
-
-
-
-
-
-|
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
-
- |
-
-
- |
-
-
-
-
-
-
-
Tests
-
-
-
-| Test |
-Duration |
-Result |
-
-
-
-| testAThousand |
-0s |
-passed |
-
-
-| testGreaterThanAThousand |
-0.001s |
-passed |
-
-
-| testGreaterThanZero |
-0s |
-passed |
-
-
-| testLessThanAThousand |
-0s |
-passed |
-
-
-| testLessThanZero |
-0s |
-passed |
-
-
-| testZero |
-0s |
-passed |
-
-
-
-
-
-
-
-
diff --git a/build/reports/tests/test/css/base-style.css b/build/reports/tests/test/css/base-style.css
deleted file mode 100644
index 4afa73e..0000000
--- a/build/reports/tests/test/css/base-style.css
+++ /dev/null
@@ -1,179 +0,0 @@
-
-body {
- margin: 0;
- padding: 0;
- font-family: sans-serif;
- font-size: 12pt;
-}
-
-body, a, a:visited {
- color: #303030;
-}
-
-#content {
- padding-left: 50px;
- padding-right: 50px;
- padding-top: 30px;
- padding-bottom: 30px;
-}
-
-#content h1 {
- font-size: 160%;
- margin-bottom: 10px;
-}
-
-#footer {
- margin-top: 100px;
- font-size: 80%;
- white-space: nowrap;
-}
-
-#footer, #footer a {
- color: #a0a0a0;
-}
-
-#line-wrapping-toggle {
- vertical-align: middle;
-}
-
-#label-for-line-wrapping-toggle {
- vertical-align: middle;
-}
-
-ul {
- margin-left: 0;
-}
-
-h1, h2, h3 {
- white-space: nowrap;
-}
-
-h2 {
- font-size: 120%;
-}
-
-ul.tabLinks {
- padding-left: 0;
- padding-top: 10px;
- padding-bottom: 10px;
- overflow: auto;
- min-width: 800px;
- width: auto !important;
- width: 800px;
-}
-
-ul.tabLinks li {
- float: left;
- height: 100%;
- list-style: none;
- padding-left: 10px;
- padding-right: 10px;
- padding-top: 5px;
- padding-bottom: 5px;
- margin-bottom: 0;
- -moz-border-radius: 7px;
- border-radius: 7px;
- margin-right: 25px;
- border: solid 1px #d4d4d4;
- background-color: #f0f0f0;
-}
-
-ul.tabLinks li:hover {
- background-color: #fafafa;
-}
-
-ul.tabLinks li.selected {
- background-color: #c5f0f5;
- border-color: #c5f0f5;
-}
-
-ul.tabLinks a {
- font-size: 120%;
- display: block;
- outline: none;
- text-decoration: none;
- margin: 0;
- padding: 0;
-}
-
-ul.tabLinks li h2 {
- margin: 0;
- padding: 0;
-}
-
-div.tab {
-}
-
-div.selected {
- display: block;
-}
-
-div.deselected {
- display: none;
-}
-
-div.tab table {
- min-width: 350px;
- width: auto !important;
- width: 350px;
- border-collapse: collapse;
-}
-
-div.tab th, div.tab table {
- border-bottom: solid #d0d0d0 1px;
-}
-
-div.tab th {
- text-align: left;
- white-space: nowrap;
- padding-left: 6em;
-}
-
-div.tab th:first-child {
- padding-left: 0;
-}
-
-div.tab td {
- white-space: nowrap;
- padding-left: 6em;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-
-div.tab td:first-child {
- padding-left: 0;
-}
-
-div.tab td.numeric, div.tab th.numeric {
- text-align: right;
-}
-
-span.code {
- display: inline-block;
- margin-top: 0em;
- margin-bottom: 1em;
-}
-
-span.code pre {
- font-size: 11pt;
- padding-top: 10px;
- padding-bottom: 10px;
- padding-left: 10px;
- padding-right: 10px;
- margin: 0;
- background-color: #f7f7f7;
- border: solid 1px #d0d0d0;
- min-width: 700px;
- width: auto !important;
- width: 700px;
-}
-
-span.wrapped pre {
- word-wrap: break-word;
- white-space: pre-wrap;
- word-break: break-all;
-}
-
-label.hidden {
- display: none;
-}
\ No newline at end of file
diff --git a/build/reports/tests/test/css/style.css b/build/reports/tests/test/css/style.css
deleted file mode 100644
index 3dc4913..0000000
--- a/build/reports/tests/test/css/style.css
+++ /dev/null
@@ -1,84 +0,0 @@
-
-#summary {
- margin-top: 30px;
- margin-bottom: 40px;
-}
-
-#summary table {
- border-collapse: collapse;
-}
-
-#summary td {
- vertical-align: top;
-}
-
-.breadcrumbs, .breadcrumbs a {
- color: #606060;
-}
-
-.infoBox {
- width: 110px;
- padding-top: 15px;
- padding-bottom: 15px;
- text-align: center;
-}
-
-.infoBox p {
- margin: 0;
-}
-
-.counter, .percent {
- font-size: 120%;
- font-weight: bold;
- margin-bottom: 8px;
-}
-
-#duration {
- width: 125px;
-}
-
-#successRate, .summaryGroup {
- border: solid 2px #d0d0d0;
- -moz-border-radius: 10px;
- border-radius: 10px;
-}
-
-#successRate {
- width: 140px;
- margin-left: 35px;
-}
-
-#successRate .percent {
- font-size: 180%;
-}
-
-.success, .success a {
- color: #008000;
-}
-
-div.success, #successRate.success {
- background-color: #bbd9bb;
- border-color: #008000;
-}
-
-.failures, .failures a {
- color: #b60808;
-}
-
-.skipped, .skipped a {
- color: #c09853;
-}
-
-div.failures, #successRate.failures {
- background-color: #ecdada;
- border-color: #b60808;
-}
-
-ul.linkList {
- padding-left: 0;
-}
-
-ul.linkList li {
- list-style: none;
- margin-bottom: 5px;
-}
diff --git a/build/reports/tests/test/index.html b/build/reports/tests/test/index.html
deleted file mode 100644
index dc59269..0000000
--- a/build/reports/tests/test/index.html
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-
-
-
-Test results - Test Summary
-
-
-
-
-
-
-
Test Summary
-
-
-
-
-
-
-
-|
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
-
- |
-
-
- |
-
-
-
-
-
-
-
Packages
-
-
-
-| Package |
-Tests |
-Failures |
-Ignored |
-Duration |
-Success rate |
-
-
-
-
-|
-io.turntabl.tcms
- |
-6 |
-0 |
-0 |
-0.001s |
-100% |
-
-
-
-
-
-
-
-
-
-
diff --git a/build/reports/tests/test/js/report.js b/build/reports/tests/test/js/report.js
deleted file mode 100644
index 83bab4a..0000000
--- a/build/reports/tests/test/js/report.js
+++ /dev/null
@@ -1,194 +0,0 @@
-(function (window, document) {
- "use strict";
-
- var tabs = {};
-
- function changeElementClass(element, classValue) {
- if (element.getAttribute("className")) {
- element.setAttribute("className", classValue);
- } else {
- element.setAttribute("class", classValue);
- }
- }
-
- function getClassAttribute(element) {
- if (element.getAttribute("className")) {
- return element.getAttribute("className");
- } else {
- return element.getAttribute("class");
- }
- }
-
- function addClass(element, classValue) {
- changeElementClass(element, getClassAttribute(element) + " " + classValue);
- }
-
- function removeClass(element, classValue) {
- changeElementClass(element, getClassAttribute(element).replace(classValue, ""));
- }
-
- function initTabs() {
- var container = document.getElementById("tabs");
-
- tabs.tabs = findTabs(container);
- tabs.titles = findTitles(tabs.tabs);
- tabs.headers = findHeaders(container);
- tabs.select = select;
- tabs.deselectAll = deselectAll;
- tabs.select(0);
-
- return true;
- }
-
- function getCheckBox() {
- return document.getElementById("line-wrapping-toggle");
- }
-
- function getLabelForCheckBox() {
- return document.getElementById("label-for-line-wrapping-toggle");
- }
-
- function findCodeBlocks() {
- var spans = document.getElementById("tabs").getElementsByTagName("span");
- var codeBlocks = [];
- for (var i = 0; i < spans.length; ++i) {
- if (spans[i].className.indexOf("code") >= 0) {
- codeBlocks.push(spans[i]);
- }
- }
- return codeBlocks;
- }
-
- function forAllCodeBlocks(operation) {
- var codeBlocks = findCodeBlocks();
-
- for (var i = 0; i < codeBlocks.length; ++i) {
- operation(codeBlocks[i], "wrapped");
- }
- }
-
- function toggleLineWrapping() {
- var checkBox = getCheckBox();
-
- if (checkBox.checked) {
- forAllCodeBlocks(addClass);
- } else {
- forAllCodeBlocks(removeClass);
- }
- }
-
- function initControls() {
- if (findCodeBlocks().length > 0) {
- var checkBox = getCheckBox();
- var label = getLabelForCheckBox();
-
- checkBox.onclick = toggleLineWrapping;
- checkBox.checked = false;
-
- removeClass(label, "hidden");
- }
- }
-
- function switchTab() {
- var id = this.id.substr(1);
-
- for (var i = 0; i < tabs.tabs.length; i++) {
- if (tabs.tabs[i].id === id) {
- tabs.select(i);
- break;
- }
- }
-
- return false;
- }
-
- function select(i) {
- this.deselectAll();
-
- changeElementClass(this.tabs[i], "tab selected");
- changeElementClass(this.headers[i], "selected");
-
- while (this.headers[i].firstChild) {
- this.headers[i].removeChild(this.headers[i].firstChild);
- }
-
- var h2 = document.createElement("H2");
-
- h2.appendChild(document.createTextNode(this.titles[i]));
- this.headers[i].appendChild(h2);
- }
-
- function deselectAll() {
- for (var i = 0; i < this.tabs.length; i++) {
- changeElementClass(this.tabs[i], "tab deselected");
- changeElementClass(this.headers[i], "deselected");
-
- while (this.headers[i].firstChild) {
- this.headers[i].removeChild(this.headers[i].firstChild);
- }
-
- var a = document.createElement("A");
-
- a.setAttribute("id", "ltab" + i);
- a.setAttribute("href", "#tab" + i);
- a.onclick = switchTab;
- a.appendChild(document.createTextNode(this.titles[i]));
-
- this.headers[i].appendChild(a);
- }
- }
-
- function findTabs(container) {
- return findChildElements(container, "DIV", "tab");
- }
-
- function findHeaders(container) {
- var owner = findChildElements(container, "UL", "tabLinks");
- return findChildElements(owner[0], "LI", null);
- }
-
- function findTitles(tabs) {
- var titles = [];
-
- for (var i = 0; i < tabs.length; i++) {
- var tab = tabs[i];
- var header = findChildElements(tab, "H2", null)[0];
-
- header.parentNode.removeChild(header);
-
- if (header.innerText) {
- titles.push(header.innerText);
- } else {
- titles.push(header.textContent);
- }
- }
-
- return titles;
- }
-
- function findChildElements(container, name, targetClass) {
- var elements = [];
- var children = container.childNodes;
-
- for (var i = 0; i < children.length; i++) {
- var child = children.item(i);
-
- if (child.nodeType === 1 && child.nodeName === name) {
- if (targetClass && child.className.indexOf(targetClass) < 0) {
- continue;
- }
-
- elements.push(child);
- }
- }
-
- return elements;
- }
-
- // Entry point.
-
- window.onload = function() {
- initTabs();
- initControls();
- };
-} (window, window.document));
\ No newline at end of file
diff --git a/build/reports/tests/test/packages/io.turntabl.tcms.html b/build/reports/tests/test/packages/io.turntabl.tcms.html
deleted file mode 100644
index 5314ce5..0000000
--- a/build/reports/tests/test/packages/io.turntabl.tcms.html
+++ /dev/null
@@ -1,103 +0,0 @@
-
-
-
-
-
-Test results - Package io.turntabl.tcms
-
-
-
-
-
-
-
Package io.turntabl.tcms
-
-
-
-
-
-
-
-
-|
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
-
- |
-
-
- |
-
-
-
-
-
-
-
Classes
-
-
-
-| Class |
-Tests |
-Failures |
-Ignored |
-Duration |
-Success rate |
-
-
-
-|
-NumbersTest
- |
-6 |
-0 |
-0 |
-0.001s |
-100% |
-
-
-
-
-
-
-
-
diff --git a/build/test-results/test/TEST-io.turntabl.tcms.NumbersTest.xml b/build/test-results/test/TEST-io.turntabl.tcms.NumbersTest.xml
deleted file mode 100644
index a9c6d12..0000000
--- a/build/test-results/test/TEST-io.turntabl.tcms.NumbersTest.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/test-results/test/binary/output.bin b/build/test-results/test/binary/output.bin
deleted file mode 100644
index e69de29..0000000
diff --git a/build/test-results/test/binary/output.bin.idx b/build/test-results/test/binary/output.bin.idx
deleted file mode 100644
index f76dd23..0000000
Binary files a/build/test-results/test/binary/output.bin.idx and /dev/null differ
diff --git a/build/test-results/test/binary/results.bin b/build/test-results/test/binary/results.bin
deleted file mode 100644
index e3b1590..0000000
Binary files a/build/test-results/test/binary/results.bin and /dev/null differ
diff --git a/clients.csv b/clients.csv
new file mode 100644
index 0000000..2d7503c
--- /dev/null
+++ b/clients.csv
@@ -0,0 +1,4 @@
+ID,Name,Address,Telephone,Email
+485934,Sarah,Madina,026334748,sarah@hotmail.com
+234,Dennis Effa,jjiadge,712 1231 1231,shdasdg@uuadas
+,Sam Moorhouse,ashdasdasd,153123 1231231,acasascas asdhgas accra
diff --git a/gradlew b/gradlew
old mode 100755
new mode 100644
diff --git a/gradlew.bat b/gradlew.bat
index e95643d..f955316 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,84 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/run b/run
new file mode 100644
index 0000000..b06c528
--- /dev/null
+++ b/run
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+echo "Making sure project is clean"
+./gradlew clean
+
+echo "Runnig Gradlew Test"
+./gradlew test
+
+echo "Building your project"
+./gradlew build
+
+./gradlew create
+
+cd build/scripts
+
+./gradle-travis-sample
\ No newline at end of file
diff --git a/src/main/java/io/turntabl/tcms/Client.java b/src/main/java/io/turntabl/tcms/Client.java
new file mode 100644
index 0000000..ce79f31
--- /dev/null
+++ b/src/main/java/io/turntabl/tcms/Client.java
@@ -0,0 +1,78 @@
+package io.turntabl.tcms;
+
+import java.io.FileWriter;
+import java.io.IOException;
+
+public class Client {
+
+ private String id;
+ private String name;
+ private String phone;
+ private String email;
+ private String address;
+
+ public Client(String id, String name, String phone, String email, String address) {
+ this.id = id;
+ this.name = name;
+ this.phone = phone;
+ this.email = email;
+ this.address = address;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void writeToFile() {
+
+ FileWriter f = null;
+ try {
+ f = new FileWriter("clients.csv", true);
+ f.append(id);
+ f.append(",");
+ f.append(name);
+ f.append(",");
+ f.append(address);
+ f.append(",");
+ f.append(phone);
+ f.append(",");
+ f.append(email);
+ f.append("\n");
+
+ }
+ catch (Exception e ){
+ e.printStackTrace();
+ }
+ finally {
+ try{
+ if (f != null){
+ if (f !=null) {
+ f.flush();
+ f.close();
+ }
+ }
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+ }
+
diff --git a/src/main/java/io/turntabl/tcms/ClientManagementSystem.java b/src/main/java/io/turntabl/tcms/ClientManagementSystem.java
new file mode 100644
index 0000000..06b37df
--- /dev/null
+++ b/src/main/java/io/turntabl/tcms/ClientManagementSystem.java
@@ -0,0 +1,170 @@
+package io.turntabl.tcms;
+
+import java.util.Scanner;
+
+
+public class ClientManagementSystem {
+
+ public static void main (String[] args) {
+ // declare a variable that will store the client details
+ String userInput;
+ String clientEmailAddress;
+
+
+ //declare a scanner object to read the command line input by user
+ Scanner sn = new Scanner(System.in);
+
+ //loop the utility in loop until the user makes the choice to exit
+
+ while(true){
+
+ //Print the options for the user to choose from
+ System.out.println("*****Welcome, Sam Moorhouse.*****");
+
+ System.out.println("*****Available Options*****");
+
+ System.out.println("*.\033[1;34m Press 1 to Enter User Details.\033[0m");
+ System.out.println("*. \033[1;34mPress 2 to View List of Clients.\033[0m");
+ System.out.println("*. \033[1;34mPress 3 to Search for a Client.\033[0m");
+ System.out.println("*. \033[1;34mPress 4 to Delete a User.\033[0m");
+ System.out.println("*. \033[1;34mPress 5 to Exit from the application.\033[0m");
+
+ // Prompt the user to make a choice
+ System.out.println("\033[1;31mEnter your choice:\033[0m");
+
+ //Capture the user input in scanner object and store it in a pre declared variable
+ userInput = sn.nextLine();
+
+ //Check the user input
+ switch(userInput) {
+ case "1":
+ //Enter Client Details;
+
+ System.out.println("\033[1;32m*.Enter Client Name. *\033[0m");
+ String userName = sn.nextLine();
+
+ System.out.println("\033[1;32m*.Enter Client Telephone. *\033[0m");
+ String phone = sn.nextLine();
+
+ System.out.println("\033[1;32m*.Enter Email Address. *\033[0m");
+ String email = sn.nextLine();
+
+ System.out.println("\033[1;32m*.Enter Address. *\033[0m");
+ String address = sn.nextLine();
+
+ int line = Utils.length() +1;
+ String newId = String.valueOf(line);
+ Client newClient = new Client(newId, userName, phone, email, address);
+ try {
+ Utils.duplicateUser(newClient);
+ newClient.writeToFile();
+ } catch (DuplicateClienException e) {
+ System.err.println(e.getMessage());
+ }
+
+ System.out.println("\n");
+
+
+ boolean proceed = Validation.isword(clientEmailAddress = email);
+ while (!proceed) {
+ System.out.println("*.Enter Email Address. *");
+ clientEmailAddress = sn.nextLine();
+ proceed = Validation.isword(clientEmailAddress);
+ }
+
+
+ System.out.println("\033[1;37mDetails saved successfully.\033[0m");
+
+ break;
+
+
+ case "2":
+// DataStore.getAllClients();
+// Utils.readFromFile();
+ System.out.println("---------------------------------------------------------------------------------------------");
+ System.out.printf("%5s %20s %15s %20s %20s", "CLIENT_ID", "CLIENT_NAMES", "PHONE", "EMAIL", "ADDRESS");
+ System.out.println();
+ System.out.println("---------------------------------------------------------------------------------------------");
+ for (Client client: Utils.readFromFile()){
+ System.out.format("%8s %20s %20s %20s %20s",
+ client.getId(), client.getName(), client.getPhone(), client.getEmail(), client.getAddress());
+ System.out.println();
+ }
+ System.out.println("---------------------------------------------------------------------------------------------");
+ System.out.println();
+ System.out.println();
+ break;
+
+
+ case "3":
+ System.out.println("\033[1;37m*. Enter your clients name*\033[0m");
+ String searchName = sn.nextLine();
+ try {
+ System.out.println("---------------------------------------------------------------------------------------------");
+ System.out.printf("%5s %20s %15s %20s %20s", "CLIENT_ID", "CLIENT_NAMES", "PHONE", "EMAIL", "ADDRESS");
+ System.out.println();
+ System.out.println("---------------------------------------------------------------------------------------------");
+// System.out.println(Utils.searchByName(searchName));
+ for(Client client:Utils.searchByName(searchName) ){
+ System.out.format("%8s %20s %20s %20s %20s",
+ client.getId(), client.getName(), client.getPhone(), client.getEmail(), client.getAddress());
+ System.out.println();
+ }
+ System.out.println("---------------------------------------------------------------------------------------------");
+ System.out.println();
+ System.out.println();
+
+ } catch (Exception clientNotFound) {
+ System.err.println(clientNotFound.getMessage());
+ System.out.println();
+ }
+// Client searchClient = searchClient.searchClient(1,"Jude");
+
+ //Search for a Client
+// System.out.println("Clienqt found or not ...");
+ break;
+
+
+
+ case "4":
+// DataStore.getAllClients();
+ System.out.println("---------------------------------------------------------------------------------------------");
+ System.out.printf("%5s %20s %15s %20s %20s", "CLIENT_ID", "CLIENT_NAMES", "PHONE", "EMAIL", "ADDRESS");
+ System.out.println();
+ System.out.println("---------------------------------------------------------------------------------------------");
+ for (Client client: Utils.readFromFile()){
+ System.out.format("%8s %20s %20s %20s %20s",
+ client.getId(), client.getName(), client.getPhone(), client.getEmail(), client.getAddress());
+ System.out.println();
+ }
+ System.out.println("---------------------------------------------------------------------------------------------");
+ System.out.println();
+ System.out.println();
+ System.out.println("\033[1;37m*. Enter Client ID*\033[0m");
+ String idToDelete = sn.nextLine();
+
+ if (idToDelete != null && idToDelete.length() != 0) {
+
+ DataStore.deleteClients(idToDelete);
+ System.out.println("Client has been Deleted Successfully");
+
+ }else {
+ System.out.println(" Empty Entry");
+ System.out.println("\n Try Again \n");
+ }
+
+ break;
+
+
+ case "5":
+
+ //Exit from the application
+ System.out.println("Exiting...");
+ System.exit(0);
+ default:
+ //Inform user in case of invalid choice.
+ System.out.println("Invalid choice. Read the options carefully...");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/io/turntabl/tcms/ClientNotFoundError.java b/src/main/java/io/turntabl/tcms/ClientNotFoundError.java
new file mode 100644
index 0000000..9f0781e
--- /dev/null
+++ b/src/main/java/io/turntabl/tcms/ClientNotFoundError.java
@@ -0,0 +1,7 @@
+package io.turntabl.tcms;
+
+public class ClientNotFoundError extends Exception {
+ public ClientNotFoundError(final String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/io/turntabl/tcms/DataStore.java b/src/main/java/io/turntabl/tcms/DataStore.java
new file mode 100644
index 0000000..85c3c4d
--- /dev/null
+++ b/src/main/java/io/turntabl/tcms/DataStore.java
@@ -0,0 +1,67 @@
+package io.turntabl.tcms;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.util.Scanner;
+
+public class DataStore {
+ private static final String filePath = "clients.csv";
+
+
+ public static void getAllClients() {
+ File file = new File(filePath);
+ try {
+ Scanner inputStream = new Scanner(file);
+ while (inputStream.hasNext()) {
+ String data = inputStream.nextLine();
+ System.out.println(data);
+ }
+ inputStream.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void deleteClients(String id) {
+
+ File file = new File(filePath);
+/*
+ try {
+ Scanner inputStream = new Scanner(file);
+ while (inputStream.hasNext()) {
+ String data = inputStream.nextLine();
+ System.out.println(data);
+ }
+ inputStream.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+*/
+ //Delete a Client
+ //Code goes here
+
+ File tempFile = new File("temp.csv");
+
+ String idToDelete = id;
+
+
+
+ try {
+
+ PrintWriter out = new PrintWriter(new FileWriter(tempFile));
+ Files.lines(file.toPath())
+ .filter(line -> !line.contains(idToDelete))
+ .forEach(out::println);
+ out.flush();
+ out.close();
+ tempFile.renameTo(file);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
+
diff --git a/src/main/java/io/turntabl/tcms/DuplicateClienException.java b/src/main/java/io/turntabl/tcms/DuplicateClienException.java
new file mode 100644
index 0000000..468eaf6
--- /dev/null
+++ b/src/main/java/io/turntabl/tcms/DuplicateClienException.java
@@ -0,0 +1,7 @@
+package io.turntabl.tcms;
+
+public class DuplicateClienException extends Exception {
+ public DuplicateClienException(final String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/io/turntabl/tcms/Utils.java b/src/main/java/io/turntabl/tcms/Utils.java
new file mode 100644
index 0000000..51a0c93
--- /dev/null
+++ b/src/main/java/io/turntabl/tcms/Utils.java
@@ -0,0 +1,130 @@
+package io.turntabl.tcms;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class Utils {
+ public static int lavenstine(String string1, String string2){
+ string1 = string1.toLowerCase();
+ string2 = string2.toLowerCase();
+
+ int [ ] costs = new int [string2.length()+1];
+ for (int j = 0; j searchByName(String search) throws ClientNotFoundError {
+ List matching = readFromFile().stream().filter(client -> lavenstine(firstWord(client.getName()), search) <2).collect(Collectors.toList());
+ if (matching.size() != 0){
+ return matching;
+ }
+ else {
+ throw new ClientNotFoundError("No client found with that name \n \n");
+ }
+ }
+
+ public static List readFromFile(){
+ List clients = new ArrayList<>();
+ Path path = Paths.get("clients.csv");
+
+ try (BufferedReader br = Files.newBufferedReader(path)) {
+ String line = br.readLine();
+ while(line != null){
+ String [] attributes = line.split(",");
+ Client client = createClient(attributes);
+ clients.add(client);
+ line = br.readLine();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return clients;
+ }
+
+ private static Client createClient(String[] attributes) {
+ String ID = attributes[0];
+ String name = attributes[1];
+ String phone = attributes[3];
+ String email = attributes[4];
+ String address = attributes[2];
+ return new Client(ID, name,phone,email,address);
+ }
+
+ public static String firstWord(String input) {
+ String result = ""; // Return empty string if no space found
+ for(int i = 0; i < input.length(); i++) {
+ if(input.charAt(i) == ' ') {
+ result = input.substring(0, i);
+ break; // because we're done
+ }
+ }
+ return result;
+ }
+ public static int length() {
+
+ File file = new File("clients.csv");
+ int lineNumberCount = 0;
+
+ if (file.exists()) {
+ try {
+ FileReader fr = new FileReader(file);
+ LineNumberReader lr = new LineNumberReader(fr);
+ try {
+ while (lr.readLine() != null) {
+ lineNumberCount++;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ return lineNumberCount;
+ }
+
+ public static boolean duplicateUser(Client client) throws DuplicateClienException{
+ for (Client c : Utils.readFromFile()) {
+ if (c.getName().equals(client.getName())){
+ if (c.getEmail().equals(client.getEmail())){
+ if (c.getPhone().equals(client.getPhone())){
+ if (c.getAddress().equals(client.getAddress())){
+ throw new DuplicateClienException("Client found with same details aborting operation....");
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/io/turntabl/tcms/Validation.java b/src/main/java/io/turntabl/tcms/Validation.java
new file mode 100644
index 0000000..c62302c
--- /dev/null
+++ b/src/main/java/io/turntabl/tcms/Validation.java
@@ -0,0 +1,10 @@
+package io.turntabl.tcms;
+import javax.swing.*;
+import java.util.regex.Pattern;
+
+public class Validation {
+
+ public static boolean isword(String in) {
+ return Pattern.matches("[a-zA-Z0-999. @]+", in);
+ }
+}
diff --git a/src/test/java/io/turntabl/tcms/ClientManagementTest.java b/src/test/java/io/turntabl/tcms/ClientManagementTest.java
new file mode 100644
index 0000000..05a3ca1
--- /dev/null
+++ b/src/test/java/io/turntabl/tcms/ClientManagementTest.java
@@ -0,0 +1,26 @@
+package io.turntabl.tcms;
+
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+public class ClientManagementTest {
+
+
+ @Test
+ public void testClient() throws IOException {
+ Client c = new Client("5454","francis","045355599","junior@gmail.com","fdsadda");
+ assertEquals("francis", c.getName());
+ }
+
+
+ @Test
+ public void testWriteToFile() throws IOException {
+ Client c = new Client("4643","chris","02340001111","tee@ymail.com","madina");
+ // c.writeToFile();
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/turntabl/tcms/DataStoreTest.java b/src/test/java/io/turntabl/tcms/DataStoreTest.java
new file mode 100644
index 0000000..985da8e
--- /dev/null
+++ b/src/test/java/io/turntabl/tcms/DataStoreTest.java
@@ -0,0 +1,135 @@
+package io.turntabl.tcms;
+
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.sql.*;
+
+//import com.ibatis.common.jdbc.ScriptRunner;
+import static org.junit.Assert.*;
+
+public class DataStoreTest {
+ private static final String dbUrl = "jdbc:h2:tcms";
+ private static final String testScriptPath = "testscript.sql";
+
+ @Test
+ public void testInMemoryDb() throws ClassNotFoundException {
+ BufferedReader reader = null;
+ Class.forName("org.h2.Driver");
+ try(Connection db = DriverManager.getConnection(dbUrl,"","")) {
+
+ Statement s = db.createStatement();
+ reader = new BufferedReader(new FileReader(testScriptPath));
+
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ s.execute(line);
+ }
+// ResultSet rs = s.executeQuery("select * from customers limit 3;");
+// System.out.println("---------------------------------------------------------------------------------------------");
+// System.out.printf("%5s %15s %15s %10s %10s", "CUST_ID", "CONTACT_NAME", "CITY", "COUNTRY", "PHONE");
+// System.out.println();
+// System.out.println("---------------------------------------------------------------------------------------------");
+// while(rs.next()){
+// System.out.format("%5s %17s %15s %10s %15s", rs.getString("customer_id"), rs.getString("contact_name"), rs.getString("city"), rs.getString("country"), rs.getString("phone"));
+// System.out.println();
+// }
+ } catch (SQLException | FileNotFoundException e) {
+ System.err.println("Error "+e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSelectQuery() throws ClassNotFoundException {
+ Class.forName("org.h2.Driver");
+ try(Connection db = DriverManager.getConnection(dbUrl,"","")) {
+ Statement s = db.createStatement();
+ ResultSet rs = s.executeQuery("select * from client;");
+// System.out.println("---------------------------------------------------------------------------------------------");
+// System.out.printf("%5s %15s %15s %10s %10s", "CUST_ID", "CONTACT_NAME", "CITY", "COUNTRY", "PHONE");
+// System.out.println();
+// System.out.println("---------------------------------------------------------------------------------------------");
+ while(rs.next()){
+ System.out.format("%5s %17s %15s %10s %15s", rs.getString("ID"), rs.getString("fName"), rs.getString("lName"), rs.getString("address"), rs.getString("email"));
+ System.out.println();
+ }
+ } catch (SQLException e) {
+ System.err.println("Connection error "+e);
+ }
+
+
+ }
+
+ @Test
+ public void testDeleteQuery() throws ClassNotFoundException{
+ Class.forName("org.h2.Driver");
+ try(Connection db = DriverManager.getConnection(dbUrl,"","")) {
+ Statement s = db.createStatement();
+ boolean rs = s.execute("delete from client where ID = 2");
+// System.out.println("---------------------------------------------------------------------------------------------");
+// System.out.printf("%5s %15s %15s %10s %10s", "CUST_ID", "CONTACT_NAME", "CITY", "COUNTRY", "PHONE");
+// System.out.println();
+// System.out.println("---------------------------------------------------------------------------------------------");
+// while(rs.next()){
+// System.out.format("%5s %17s %15s %10s %15s", rs.getString("ID"), rs.getString("fName"), rs.getString("lName"), rs.getString("address"), rs.getString("email"));
+// System.out.println();
+// }
+ System.out.println(rs);
+
+ } catch (SQLException e) {
+ System.err.println("Connection error "+e);
+ }
+
+
+ }
+
+ @Test
+ public void testUpdateQuery() throws ClassNotFoundException{
+ Class.forName("org.h2.Driver");
+ try(Connection db = DriverManager.getConnection(dbUrl,"","")) {
+ Statement s = db.createStatement();
+ boolean rs = s.execute("update client set fName = 'Francis' where ID =1");
+// System.out.println("---------------------------------------------------------------------------------------------");
+// System.out.printf("%5s %15s %15s %10s %10s", "CUST_ID", "CONTACT_NAME", "CITY", "COUNTRY", "PHONE");
+// System.out.println();
+// System.out.println("---------------------------------------------------------------------------------------------");
+// while(rs.next()){
+// System.out.format("%5s %17s %15s %10s %15s", rs.getString("ID"), rs.getString("fName"), rs.getString("lName"), rs.getString("address"), rs.getString("email"));
+// System.out.println();
+// }
+ System.out.println(rs);
+
+ } catch (SQLException e) {
+ System.err.println("Connection error "+e);
+ }
+
+ }
+
+ @Test
+ public void testInsertQuery() throws ClassNotFoundException{
+ Class.forName("org.h2.Driver");
+ try(Connection db = DriverManager.getConnection(dbUrl,"","")) {
+ Statement s = db.createStatement();
+ boolean rs = s.execute("insert into client(fName,lName,address,telephone,email) values('yes', 'no', 'Burkina','0275876542', 'francis@gmail.com')");
+// System.out.println("---------------------------------------------------------------------------------------------");
+// System.out.printf("%5s %15s %15s %10s %10s", "CUST_ID", "CONTACT_NAME", "CITY", "COUNTRY", "PHONE");
+// System.out.println();
+// System.out.println("---------------------------------------------------------------------------------------------");
+// while(rs.next()){
+// System.out.format("%5s %17s %15s %10s %15s", rs.getString("ID"), rs.getString("fName"), rs.getString("lName"), rs.getString("address"), rs.getString("email"));
+// System.out.println();
+// }
+ System.out.println(rs);
+
+ } catch (SQLException e) {
+ System.err.println("Connection error "+e);
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/io/turntabl/tcms/NumbersTest.java b/src/test/java/io/turntabl/tcms/NumbersTest.java
index d034a0d..12b573f 100644
--- a/src/test/java/io/turntabl/tcms/NumbersTest.java
+++ b/src/test/java/io/turntabl/tcms/NumbersTest.java
@@ -8,7 +8,7 @@ public class NumbersTest {
@Test
public void testLessThanZero() {
- boolean result = Numbers.isGreaterThanZeroAndLessThanAThousand(-1);
+ boolean result = Numbers.isGreaterThanZeroAndLessThanAThousand(-3);
assertFalse(result);
}
diff --git a/src/test/java/io/turntabl/tcms/UtilsTest.java b/src/test/java/io/turntabl/tcms/UtilsTest.java
new file mode 100644
index 0000000..4e68a51
--- /dev/null
+++ b/src/test/java/io/turntabl/tcms/UtilsTest.java
@@ -0,0 +1,46 @@
+package io.turntabl.tcms;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.*;
+
+public class UtilsTest {
+ @Test
+ public void testDistance(){
+ assertEquals(3, Utils.lavenstine("Flomax", "Volmax"));
+ }
+
+ @Test
+ public void testDistance2(){
+ assertEquals(4, Utils.lavenstine("Dennis", "Bernice"));
+ }
+
+ @Test
+ public void testReadingDataFromFile(){
+ System.out.println(Utils.readFromFile());
+ }
+ @Test
+ public void testMatchingStrings() {
+// assertEquals(Arrays.asList(c),Utils.searchByName("Dennis"));
+ try {
+ assertNotEquals("Dennis",Utils.searchByName("as"));
+ } catch (Exception clientNotFound) {
+ clientNotFound.getMessage();
+ }
+ }
+ @Test
+ public void testFirstName(){
+ assertEquals("Dennis", Utils.firstWord("Dennis Effa"));
+ }
+ @Test
+ public void duplicateUser(){
+ Client cc = new Client("234","Dennis","123","abc","abc");
+ try{
+ System.out.println(Utils.duplicateUser(cc));
+ } catch (DuplicateClienException e) {
+ e.getMessage();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/turntabl/tcms/ValidationTest.java b/src/test/java/io/turntabl/tcms/ValidationTest.java
new file mode 100644
index 0000000..396d47e
--- /dev/null
+++ b/src/test/java/io/turntabl/tcms/ValidationTest.java
@@ -0,0 +1,26 @@
+package io.turntabl.tcms;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class ValidationTest {
+ @Test
+ public void testValidateEmail(){
+
+ assertTrue(Validation.isword("James"));
+ }
+
+ @Test
+ public void testCharactersOnEmail(){
+
+ assertFalse(Validation.isword("&&^%"));
+ }
+
+ @Test
+ public void testRealEmail(){
+ assertTrue(Validation.isword("teebill@gmail.com"));
+ }
+
+
+}
\ No newline at end of file
diff --git a/.gradle/4.10.3/fileHashes/resourceHashesCache.bin b/tcms.h2.db
similarity index 79%
rename from .gradle/4.10.3/fileHashes/resourceHashesCache.bin
rename to tcms.h2.db
index ba301e9..817a871 100644
Binary files a/.gradle/4.10.3/fileHashes/resourceHashesCache.bin and b/tcms.h2.db differ
diff --git a/testscript.sql b/testscript.sql
new file mode 100644
index 0000000..d3305ef
--- /dev/null
+++ b/testscript.sql
@@ -0,0 +1,5 @@
+drop table if exists client;
+create table client(ID serial primary key not null,fName varchar(50) not null,lName varchar(50) not null,address varchar(100) not null,telephone varchar(50) not null,email varchar(50));
+
+insert into client(fName,lName,address,telephone,email) values('Dennis', 'Christy', 'Burkina','0275876542', 'francis@gmail.com');
+insert into client(fName,lName,address,telephone,email) values('Bill', 'Christy','Achimota', '0244-2723-23-123', 'tcms@yahoo.com');
\ No newline at end of file