Giter VIP home page Giter VIP logo

ece-shopping's Introduction

ece-shopping's People

Contributors

ange980 avatar bragdond avatar dependabot[bot] avatar hugovdal11 avatar sarahab1 avatar

Stargazers

 avatar

Watchers

 avatar

ece-shopping's Issues

Create Sqlite Integration to make testing easier

Task Description :

The objective of this task is to create an integration for SQLite, which will enable easier testing of the project. This integration will allow us to use SQLite as a lightweight database for testing purposes, which can be easily set up and torn down as needed.

Why SQlite ?

By using SQLite for testing, we can ensure that our code is functioning correctly without the need for a full-fledged database setup. This will also reduce the overhead of testing, as SQLite can be run entirely in-memory, making tests faster and more efficient. The end result of this task will be a more streamlined and efficient testing process for the project,

Create User Service Class

Task Description:

Create User Service Class

Task Details:

The objective of this task is to create a User Service class that will act as an interface between the User DAO class and the rest of the application. The User Service class will contain methods to handle CRUD (Create, Read, Update, Delete) operations on User objects.

Task Checklist:

  • Define a package for the User Service class.
  • Create a User Service class.
  • Define methods for CRUD operations on User objects.
  • Use dependency injection to inject the User DAO interface into the User Service class.
  • Implement the CRUD operations using methods from the User DAO interface.
  • Implement any additional business logic required for the User Service class.
  • Write unit tests to test the methods in the User Service class.
  • Test the User Service class in the application to ensure it is functioning as expected.

Additional Resources:

  • Java documentation on Service classes.
  • Java documentation on Dependency Injection.

Create User Model Class with Hibernate

Task description:

Create a User Model class using Hibernate to map to the Users table in the database. The User Model class should contain the following attributes:

  • id: integer, primary key, auto-incremented
  • email: string, unique, not null
  • password: string, not null
  • name: string, not null
  • admin: boolean, not null

The User Model class should also include appropriate getter and setter methods for each attribute.

The User Model class should be mapped to the Users table in the database using Hibernate annotations. The appropriate Hibernate annotations should be added to each attribute to specify the corresponding database column name, data type, and any constraints.

All code should adhere to best practices and be well-documented. Unit tests should also be written to ensure the correct functioning of the User Model class.

Need to solve the Router Garbage Collector Problem

We have identified a problem where the views and the controller are always being destroyed and not stored. This is causing issues with the functionality of our application, as the views and controller are essential components for managing user interactions and displaying information.

To solve this problem, we will need to review the code and identify why the views and controller are not being stored properly. We will work together to implement a solution that ensures that the views and controller are properly stored and can be accessed when needed.

We will conduct thorough testing to ensure that the solution is effective and does not introduce any new issues or bugs. Our ultimate goal is to create a stable and reliable application that provides a seamless experience for our users.

Create User DAO Class

Task Description:

Create a User DAO (Data Access Object) class for accessing the User Model using Hibernate ORM (Object-Relational Mapping).

Task Details:

The User DAO class will implement the User DAO interface and provide the implementation for the methods defined in the interface. The DAO class will be responsible for performing CRUD (Create, Read, Update, Delete) operations on the User Model using Hibernate ORM. The DAO class will also handle database transactions and exceptions.

The User DAO class will have the following methods:

  • createUser(User user): This method will create a new User object in the database.
  • getUserById(int id): This method will retrieve a User object from the database by its ID.
  • updateUser(User user): This method will update a User object in the database.
  • deleteUser(int id): This method will delete a User object from the database by its ID.
  • getUserByEmail(String email): This method will retrieve a User object from the database by its email.
  • getAllUsers(): This method will retrieve a list of all User objects from the database.
  • getUserByAuthentication(String email, String password): This method will retrieve a User object from the database by its email and password for authentication.

The User DAO class will use Hibernate to interact with the database and will handle Hibernate session management, transactions, and exceptions.

The User DAO class will also have unit tests to verify that each method works as expected.

Create User DAO Interface Class

Task Description:

Create User DAO Interface Class

This task involves creating a Data Access Object (DAO) interface for the User model class. The DAO interface will define the methods that can be used to interact with the User model and the underlying database using Hibernate ORM.

The User DAO interface should include the following methods:

  • createUser(User user): Create a new user record in the database.
  • getUserById(int id): Retrieve a user record from the database by its ID.
  • getUserByEmail(String email): Retrieve a user record from the database by its email.
  • updateUser(User user): Update an existing user record in the database.
  • deleteUser(User user): Delete a user record from the database.

The interface should also define any additional methods required to support the User model and its relationships with other models in the system.

Additional resources:

Refer to the Hibernate documentation for guidance on creating DAO interfaces with Hibernate.

Create User Model Test for TDD with JUnit

Description

This task involves creating unit tests for the User model class.

What is TDD

Refer to the wiki page on TDD

Tests needed

  • testCreateUser: This test will create a new user and verify that the user is added to the Users table in the database.
  • testGetUserById: This test will retrieve a user by their ID from the Users table and verify that the returned user matches the expected user.
  • testUpdateUser: This test will update a user's information in the Users table and verify that the changes are reflected in the database.
  • testDeleteUser: This test will delete a user from the Users table and verify that the user is no longer present in the database.
  • testGetUserByEmail: This test will retrieve a user by their email address from the Users table and verify that the returned user matches the expected user.
  • testGetAllUsers: This test will retrieve all users from the Users table and verify that the number of users returned matches the expected count.
  • testUserIsAdmin: This test will verify that a user's admin status is correctly set and retrieved from the Users table.
  • testUserAuthentication: This test will verify that a user's email and password match the values in the Users table and that the user is authenticated.
  • testAddGrade: This test will add a grade for a product to the Grades table and verify that the grade is correctly stored.
  • testGetGradeByUserAndProduct: This test will retrieve a grade for a product by a specific user from the Grades table and verify that the returned grade matches the expected value.

Additional ressource

Refer to the wiki

Improve User Dao

  • Use try-with-resources for all sessions :
    In the current implementation, try-with-resources is used only for some of the sessions. It's recommended to use it for all sessions to ensure that resources are properly closed even in case of exceptions.

  • Use named queries :
    Instead of creating queries as string literals, you can use named queries. Named queries are defined in the entity class and provide type safety and better readability.

  • Use a DAO base class :
    You can create a base class for DAOs that implements the common CRUD methods, such as save, update, delete, and getById. This can reduce boilerplate code and improve code reuse.

  • Use interfaces for repositories :
    You can create interfaces for your repositories to promote loose coupling and dependency inversion. The interfaces define the repository contract, and the implementations provide the actual implementation.

  • Simplify exception handling :
    In the current implementation, RuntimeException is used to indicate that a user does not exist. It's recommended to use a more specific exception, such as EntityNotFoundException or UserNotFoundException, to provide better context and debugging information. Additionally, ConstraintViolationException is thrown if there are validation violations, but the exception message does not provide any details about the violations. You can customize the exception message to provide more meaningful feedback to the user.

  • Add logging :
    Adding logging statements can help with debugging and troubleshooting. You can use a logging framework, such as Log4j or SLF4J, to log messages at different levels of severity, such as info, debug, warn, or error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.