Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #85

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Dev #85

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/parkingsystem.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
5 changes: 5 additions & 0 deletions .idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/sonarlint/securityhotspotstore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>parkingsystem</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.jkiss.dbeaver.DBeaverNature</nature>
</natures>
</projectDescription>
5 changes: 5 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
59 changes: 24 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,38 @@
# Parking System
A command line app for managing the parking system.
This app uses Java to run and stores the data in Mysql DB.
Parking System

## Getting Started
Description

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Ce projet est une application de gestion de système de parking. Il permet de gérer les places de parking pour les voitures et les motos dans un parking.

### Prerequisites
Fonctionnalités :

What things you need to install the software and how to install them
Gestion des places de parking pour les voitures et les motos
Enregistrement des tickets de parking
Calcul des frais de stationnement
Logs d'activité

- Java 1.8
- Maven 3.6.2
- Mysql 8.0.17
Technologies utilisées :

### Installing
Java 15.0.2
MySQL 8.0.33
Maven 3.9.3 pour la gestion des dépendances
JUnit 5.9.2 pour les tests
Mockito 5.2.0 pour les tests unitaires avec des mocks
Log4j 1.2.17 pour la journalisation

A step by step series of examples that tell you how to get a development env running:
Le projet utilise MySQL pour la gestion de la base de données. Vous pouvez trouver les scripts SQL pour créer la base de données et les tables dans le dossier resources.

1.Install Java:
Comment exécuter l'application :

https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html
Clonez le dépôt Git sur votre machine locale.
Ouvrez le projet dans un IDE de votre choix (par exemple, IntelliJ IDEA ou Eclipse).
Assurez-vous que vous avez une instance de MySQL en cours d'exécution.
Mettez à jour les informations de connexion à la base de données dans le fichier de configuration.
Exécutez l'application.

2.Install Maven:
Licence :

https://maven.apache.org/install.html
Ce projet est sous licence MIT - voir le fichier LICENSE.md pour plus de détails.

3.Install MySql:

https://dev.mysql.com/downloads/mysql/

After downloading the mysql 8 installer and installing it, you will be asked to configure the password for the default `root` account.
This code uses the default root account to connect and the password can be set as `rootroot`. If you add another user/credentials make sure to change the same in the code base.

### Running App

Post installation of MySQL, Java and Maven, you will have to set up the tables and data in the data base.
For this, please run the sql commands present in the `Data.sql` file under the `resources` folder in the code base.

Finally, you will be ready to import the code into an IDE of your choice and run the App.java to launch the application.

### Testing

The app has unit tests and integration tests written. More of these need to be added and in some places that can be seen mentioend as `TODO` comments. The existing tests need to be triggered from maven-surefire plugin while we try to generate the final executable jar file.

To run the tests from maven, go to the folder that contains the pom.xml file and execute the below command.

`mvn test`
83 changes: 83 additions & 0 deletions database_dump.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
-- MySQL dump 10.13 Distrib 8.0.33, for macos13.3 (x86_64)
--
-- Host: localhost Database: prod
-- ------------------------------------------------------
-- Server version 8.0.33

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `parking`
--

DROP TABLE IF EXISTS `parking`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `parking` (
`PARKING_NUMBER` int NOT NULL,
`AVAILABLE` tinyint(1) NOT NULL,
`TYPE` varchar(10) NOT NULL,
PRIMARY KEY (`PARKING_NUMBER`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `parking`
--

LOCK TABLES `parking` WRITE;
/*!40000 ALTER TABLE `parking` DISABLE KEYS */;
INSERT INTO `parking` VALUES (1,1,'CAR'),(2,0,'CAR'),(3,0,'CAR'),(4,0,'BIKE'),(5,0,'BIKE'),(12,0,'CAR');
/*!40000 ALTER TABLE `parking` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `ticket`
--

DROP TABLE IF EXISTS `ticket`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ticket` (
`ID` int NOT NULL AUTO_INCREMENT,
`PARKING_NUMBER` int NOT NULL,
`VEHICLE_REG_NUMBER` varchar(10) NOT NULL,
`PRICE` double DEFAULT NULL,
`IN_TIME` datetime NOT NULL,
`OUT_TIME` datetime DEFAULT NULL,
`discount` tinyint(1) DEFAULT '0',
PRIMARY KEY (`ID`),
KEY `PARKING_NUMBER` (`PARKING_NUMBER`),
CONSTRAINT `ticket_ibfk_1` FOREIGN KEY (`PARKING_NUMBER`) REFERENCES `parking` (`PARKING_NUMBER`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `ticket`
--

LOCK TABLES `ticket` WRITE;
/*!40000 ALTER TABLE `ticket` DISABLE KEYS */;
INSERT INTO `ticket` VALUES (1,1,'ABCDE',370.9190671666667,'2023-07-13 16:58:45','2023-07-24 13:16:24',0),(2,4,'ABCDE',0,'2023-07-13 17:02:56',NULL,0),(3,5,'CE547DH',307.87258052777776,'2023-07-13 20:39:16','2023-07-27 08:43:51',0),(4,1,'ABCDE',0,'2023-07-14 05:52:40',NULL,0),(5,2,'ABCDE',0,'2023-07-15 18:27:16',NULL,0),(6,3,'HYJKV',0,'2023-07-15 18:32:12',NULL,0),(7,1,'CE547DH',0,'2023-07-21 07:22:15',NULL,0),(8,5,'POIUYTR',2.967820277777778,'2023-07-24 10:12:10','2023-07-24 13:10:14',0),(9,5,'AZERTY',129.09332694444444,'2023-07-24 13:11:22','2023-07-29 22:16:58',0),(10,1,'ABCDEF',145.60905114583332,'2023-07-26 10:44:43','2023-07-30 16:55:37',1),(11,1,'ABCDEF',0,'2023-07-26 10:45:40',NULL,0),(13,12,'ABCDEF',10,'2023-07-26 11:12:38',NULL,0),(14,5,'WXCVBN',0.0051805555555555554,'2023-07-28 07:56:46','2023-07-28 07:57:05',0),(15,1,'RTYUIO',0,'2023-07-28 07:58:27',NULL,0),(16,12,'ABCDEF',0,'2023-07-29 21:16:15',NULL,0),(17,1,'ABCDEF',0,'2023-07-29 21:18:00',NULL,0),(18,5,'ABCDEF',0,'2023-07-29 22:17:36',NULL,0),(19,1,'ABCDEF',0,'2023-07-30 16:54:54',NULL,0);
/*!40000 ALTER TABLE `ticket` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2023-07-31 11:58:52
3 changes: 3 additions & 0 deletions my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mysqld]
default_authentication_plugin=caching_sha2_password

Loading