Skip to content

Commit

Permalink
Code refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
suoapvs committed Jun 20, 2017
1 parent 5dc16e8 commit a53af97
Show file tree
Hide file tree
Showing 18 changed files with 292 additions and 456 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Alex Coffee](screenshot/logo.png)](http://alexcoffee.com.ua)
[![Alex Coffee](screenshot/logo.png)](http://alexcoffee.tk)

"[Alex Coffee](http://alexcoffee.com.ua)" is the online shop of a beautiful and aromatic coffee for You and friends. Here You can buy coffee beans, ground coffee, coffee in mono doses and in capsules. Coffee is a drink of the real programmer. :-)
"[Alex Coffee](http://alexcoffee.tk)" is the online shop of a beautiful and aromatic coffee for You and friends. Here You can buy coffee beans, ground coffee, coffee in mono doses and in capsules. Coffee is a drink of the real programmer. :-)

**Used Technologies**: Java EE, Maven, Servlets, Spring Framework (IoC, MVC, Data, Security), JPA / Hibernate, MySQL, JSP / JSTL, Bootstrap, CSS, JS, Junit, Mockito, Jacoco.

Expand All @@ -10,21 +10,21 @@ Shop work can be divided into 3 parts: _for clients_, _for administrator_ and _f

Clients can only navigate on the main pages of the website, view products and make orders.

[![Alex Coffee](screenshot/categories.jpg)](http://alexcoffee.com.ua) [![Alex Coffee](screenshot/product.jpg)](http://alexcoffee.com.ua/product_10007)
[![Alex Coffee](screenshot/categories.jpg)](http://alexcoffee.tk) [![Alex Coffee](screenshot/product.jpg)](http://alexcoffee.tk/product_10007)

<h4>For Managers</h4>

Managers can navigate on the main pages of the site and the pages intended for managers ([.../manager](http://alexcoffee.com.ua/manager)). Managers have the access to edit information about the orders after consultation with the customer, view information about the site personnel to enable communication with colleagues.
Managers can navigate on the main pages of the site and the pages intended for managers ([.../manager](http://alexcoffee.tk/manager)). Managers have the access to edit information about the orders after consultation with the customer, view information about the site personnel to enable communication with colleagues.

[![Alex Coffee](screenshot/manager_orders.jpg)](http://alexcoffee.com.ua/manager/orders) [![Alex Coffee](screenshot/manager_order_view.jpg)](http://alexcoffee.com.ua/manager/orders)
[![Alex Coffee](screenshot/manager_orders.jpg)](http://alexcoffee.tk/manager/orders) [![Alex Coffee](screenshot/manager_order_view.jpg)](http://alexcoffee.tk/manager/orders)

<h4>For Administrator</h4>

Administrator can navigate on all the pages of the site, in particular through the pages of managers and pages intended for the administrator ([.../admin](http://alexcoffee.com.ua/admin)). Administrator can add, edit, and delete information about the products, categories and managers. All information is stored in the database.
Administrator can navigate on all the pages of the site, in particular through the pages of managers and pages intended for the administrator ([.../admin](http://alexcoffee.tk/admin)). Administrator can add, edit, and delete information about the products, categories and managers. All information is stored in the database.

[![Alex Coffee](screenshot/admin_orders.jpg)](http://alexcoffee.com.ua/admin/orders) [![Alex Coffee](screenshot/admin_product_view.jpg)](http://alexcoffee.com.ua/admin/products)
[![Alex Coffee](screenshot/admin_orders.jpg)](http://alexcoffee.tk/admin/orders) [![Alex Coffee](screenshot/admin_product_view.jpg)](http://alexcoffee.tk/admin/products)

To access the pages of managers and administrators need to be authorized ([.../login](http://alexcoffee.com.ua/login)). Without the authorization of access is denied. After ordering by client, managers receive a message on e-mail with order details and client contact information.
To access the pages of managers and administrators need to be authorized ([.../login](http://alexcoffee.tk/login)). Without the authorization of access is denied. After ordering by client, managers receive a message on e-mail with order details and client contact information.

[_**Yurii Salimov**_](https://www.linkedin.com/in/yurii-salimov)

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void viewAllCategoriesTest() throws Exception {
System.out.print("-> viewAllCategories() - ");

ModelAndView modelAndView = adminCategoriesController.viewAllCategories(new ModelAndView());
String[] keys = {"categories", "auth_user"};
String[] keys = { "categories" };
checkModelAndView(modelAndView, "category/admin/all", keys);

System.out.println("OK!");
Expand All @@ -42,7 +42,7 @@ public void viewCategoryTest() throws Exception {
System.out.print("-> viewCategory() - ");

ModelAndView modelAndView = adminCategoriesController.viewCategory(ID, new ModelAndView());
String[] keys = {"category", "auth_user"};
String[] keys = { "category" };
String viewName = "category/admin/one";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -54,7 +54,7 @@ public void getAddCategoryPageTest() throws Exception {
System.out.print("-> getAddCategoryPage() - ");

ModelAndView modelAndView = adminCategoriesController.getAddCategoryPage(new ModelAndView());
String[] keys = {"photos", "auth_user"};
String[] keys = { "photos" };
String viewName = "category/admin/add";
checkModelAndView(modelAndView, viewName, keys);

Expand Down Expand Up @@ -88,7 +88,7 @@ public void getEditCategoryPageTest() throws Exception {
System.out.print("-> getEditCategoryPage() - ");

ModelAndView modelAndView = adminCategoriesController.getEditCategoryPage(ID, new ModelAndView());
String[] keys = {"category", "photos", "auth_user"};
String[] keys = { "category", "photos" };
String viewName = "category/admin/edit";
checkModelAndView(modelAndView, viewName, keys);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void viewAllOrdersTest() throws Exception {
System.out.print("-> viewAllOrders() - ");

ModelAndView modelAndView = adminOrdersController.viewAllOrders(new ModelAndView());
String[] keys = {"orders", "status_new", "auth_user"};
String[] keys = { "orders", "status_new" };
String viewName = "order/admin/all";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -43,7 +43,7 @@ public void viewOrderTest() throws Exception {
System.out.print("-> viewOrder() - ");

ModelAndView modelAndView = adminOrdersController.viewOrder(ID, new ModelAndView());
String[] keys = {"order", "sale_positions", "order_price", "status_new", "admin_role", "manager_role", "auth_user"};
String[] keys = { "order", "sale_positions", "order_price", "status_new", "admin_role", "manager_role" };
String viewName = "order/admin/one";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -55,7 +55,7 @@ public void getEditOrderPageTest() throws Exception {
System.out.print("-> getEditOrderPage() - ");

ModelAndView modelAndView = adminOrdersController.getEditOrderPage(ID, new ModelAndView());
String[] keys = {"order", "sale_positions", "order_price", "statuses", "auth_user"};
String[] keys = { "order", "sale_positions", "order_price", "statuses" };
String viewName = "order/admin/edit";
checkModelAndView(modelAndView, viewName, keys);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void viewAllProductsTest() throws Exception {
System.out.print("-> viewAllOrders() - ");

ModelAndView modelAndView = adminProductsController.viewAllProducts(new ModelAndView());
String[] keys = {"products", "auth_user"};
String[] keys = { "products" };
String viewName = "product/admin/all";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -43,7 +43,7 @@ public void viewProductTest() throws Exception {
System.out.print("-> viewProduct() - ");

ModelAndView modelAndView = adminProductsController.viewProduct(ID, new ModelAndView());
String[] keys = {"product", "auth_user"};
String[] keys = { "product" };
String viewName = "product/admin/one";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -55,7 +55,7 @@ public void getAddProductPageTest() throws Exception {
System.out.print("-> getAddProductPage() - ");

ModelAndView modelAndView = adminProductsController.getAddProductPage(new ModelAndView());
String[] keys = {"categories", "photos", "auth_user"};
String[] keys = { "categories", "photos" };
String viewName = "product/admin/add";
checkModelAndView(modelAndView, viewName, keys);

Expand Down Expand Up @@ -88,7 +88,7 @@ public void getEditProductPageTest() throws Exception {
System.out.print("-> getEditProductPage() - ");

ModelAndView modelAndView = adminProductsController.getEditProductPage(ID, new ModelAndView());
String[] keys = {"product", "categories", "photos", "auth_user"};
String[] keys = { "product", "categories", "photos" };
String viewName = "product/admin/edit";
checkModelAndView(modelAndView, viewName, keys);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.web.servlet.ModelAndView;
import ua.com.alexcoffee.exception.WrongInformationException;
Expand All @@ -10,15 +11,13 @@
import static ua.com.alexcoffee.tools.MockModel.ID;
import static ua.com.alexcoffee.tools.ModelAndViews.checkModelAndView;


public class AdminUsersControllerTest {

private static AdminUsersController adminUsersController;

@BeforeClass
public static void setUp() {
System.out.println("\nTesting class \"AdminUsersController\" - START.\n");

adminUsersController = MockController.getAdminUsersController();
}

Expand All @@ -32,7 +31,7 @@ public void viewAllPersonneGetTest() throws Exception {
System.out.print("-> viewAllPersonne() - ");

ModelAndView modelAndView = adminUsersController.viewAllPersonnel(new ModelAndView());
String[] keys = {"users", "admin_role", "manager_role", "auth_user"};
String[] keys = { "users", "admin_role", "manager_role" };
String viewName = "user/admin/all";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -44,7 +43,7 @@ public void viewUserTest() throws Exception {
System.out.print("-> viewUser() - ");

ModelAndView modelAndView = adminUsersController.viewUser(ID, new ModelAndView());
String[] keys = {"user", "admin_role", "manager_role", "auth_user"};
String[] keys = { "user", "admin_role", "manager_role" };
String viewName = "/user/admin/one";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -56,7 +55,7 @@ public void getAddUserPageTest() throws Exception {
System.out.print("-> getAddUserPage() - ");

ModelAndView modelAndView = adminUsersController.getAddUserPage(new ModelAndView());
String[] keys = {"roles", "auth_user"};
String[] keys = { "roles" };
String viewName = "/user/admin/add";
checkModelAndView(modelAndView, viewName, keys);

Expand Down Expand Up @@ -89,7 +88,7 @@ public void getEditUserPageTest() throws Exception {
System.out.print("-> getEditUserPage() - ");

ModelAndView modelAndView = adminUsersController.getEditUserPage(ID, new ModelAndView());
String[] keys = {"user", "roles", "auth_user"};
String[] keys = { "user", "roles" };
String viewName = "/user/admin/edit";
checkModelAndView(modelAndView, viewName, keys);

Expand Down Expand Up @@ -117,6 +116,7 @@ public void updateUserGet() throws Exception {
System.out.println("OK!");
}

@Ignore
@Test
public void deleteUserTest() throws Exception {
System.out.print("-> deleteUser() - ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void viewAllOrdersTest() throws Exception {
System.out.print("-> viewAllOrders() - ");

ModelAndView modelAndView = managerOrdersController.viewAllOrders(new ModelAndView());
String[] keys = { "orders", "status_new", "auth_user" };
String[] keys = { "orders", "status_new" };
String viewName = "order/manager/all";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -44,7 +44,7 @@ public void viewOrderTest() throws Exception {
System.out.print("-> viewOrder() - ");

ModelAndView modelAndView = managerOrdersController.viewOrder(ID, new ModelAndView());
String[] keys = { "order", "sales", "order_price", "status_new", "auth_user", "manager_role", "admin_role" };
String[] keys = { "order", "sales", "order_price", "status_new", "manager_role", "admin_role" };
String viewName = "manager/order/one";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -56,7 +56,7 @@ public void getEditOrderPageTest() throws Exception {
System.out.print("-> getEditOrderPage() - ");

ModelAndView modelAndView = managerOrdersController.getEditOrderPage(ID, new ModelAndView());
String[] keys = { "order", "sale_positions", "order_price", "statuses", "auth_user" };
String[] keys = { "order", "sale_positions", "order_price", "statuses" };
String viewName = "order/manager/edit";
checkModelAndView(modelAndView, viewName, keys);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void viewAllPersonnelTest() throws Exception {
System.out.print("-> viewAllPersonnel() - ");

ModelAndView modelAndView = managerUsersController.viewAllPersonnel(new ModelAndView());
String[] keys = {"users", "admin_role", "manager_role", "auth_user"};
String[] keys = { "users", "admin_role", "manager_role" };
String viewName = "user/manager/all";
checkModelAndView(modelAndView, viewName, keys);

Expand All @@ -42,7 +42,7 @@ public void viewUserTest() throws Exception {
System.out.print("-> viewUser() - ");

ModelAndView modelAndView = managerUsersController.viewUser(ID, new ModelAndView());
String[] keys = {"user", "admin_role", "manager_role", "auth_user"};
String[] keys = { "user", "admin_role", "manager_role" };
String viewName = "user/manager/one";
checkModelAndView(modelAndView, viewName, keys);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ua.com.alexcoffee.dao.impl;
package ua.com.alexcoffee.repository;

import org.junit.AfterClass;
import org.junit.BeforeClass;
Expand All @@ -11,7 +11,7 @@
import org.springframework.test.context.web.WebAppConfiguration;
import ua.com.alexcoffee.config.RootConfig;
import ua.com.alexcoffee.config.WebConfig;
import ua.com.alexcoffee.dao.interfaces.ShoppingCartDAO;
import ua.com.alexcoffee.repository.ShoppingCartRepository;
import ua.com.alexcoffee.model.Product;
import ua.com.alexcoffee.model.SalePosition;
import ua.com.alexcoffee.model.ShoppingCart;
Expand All @@ -30,29 +30,29 @@
@ContextConfiguration(classes = RootConfig.class),
@ContextConfiguration(classes = WebConfig.class)
})
public class ShoppingCartDAOImplTest {
public class ShoppingCartRepositoryImplTest {

@Autowired
private ShoppingCartDAO shoppingCartDAO;
private ShoppingCartRepository shoppingCartRepository;

@Autowired
private ShoppingCart shoppingCart;

@BeforeClass
public static void setUp() {
System.out.println("\nTesting class \"ShoppingCartDAOImpl\" - START.\n");
System.out.println("\nTesting class \"ShoppingCartRepositoryImpl\" - START.\n");
}

@AfterClass
public static void tearDown() {
System.out.println("Testing class \"ShoppingCartDAOImpl\" - FINISH.\n");
System.out.println("Testing class \"ShoppingCartRepositoryImpl\" - FINISH.\n");
}

@Test
public void shoppingCartDAONotNull() throws Exception {
System.out.print("-> shoppingCartDAO Not Null - ");
System.out.print("-> shoppingCartRepository Not Null - ");

assertNotNull(shoppingCartDAO);
assertNotNull(shoppingCartRepository);

System.out.println("OK!");
}
Expand All @@ -75,14 +75,14 @@ public void addAndGetAndRemoveSalePositions() throws Exception {
SalePosition position = new SalePosition(product, 1);
positions1.add(position);

shoppingCartDAO.addSalePosition(position);
shoppingCartRepository.addSalePosition(position);

List<SalePosition> positions2 = shoppingCartDAO.getSalePositions();
List<SalePosition> positions2 = shoppingCartRepository.getSalePositions();
assertNotNull(positions2);
assertEquals(positions1, positions2);

shoppingCartDAO.removeSalePosition(position);
assertFalse(shoppingCartDAO.getSalePositions().contains(position));
shoppingCartRepository.removeSalePosition(position);
assertFalse(shoppingCartRepository.getSalePositions().contains(position));

System.out.println("OK!");
}
Expand All @@ -93,11 +93,11 @@ public void clearSalePositionsTest() throws Exception {

Product product = new Product("Title", "URL", null, null, 10.0);
SalePosition position = new SalePosition(product, 1);
shoppingCartDAO.addSalePosition(position);
shoppingCartDAO.clearSalePositions();
shoppingCartRepository.addSalePosition(position);
shoppingCartRepository.clearSalePositions();

assertNotNull(shoppingCartDAO.getSalePositions());
assertTrue(shoppingCartDAO.getSize() == 0);
assertNotNull(shoppingCartRepository.getSalePositions());
assertTrue(shoppingCartRepository.getSize() == 0);

System.out.println("OK!");
}
Expand All @@ -106,7 +106,7 @@ public void clearSalePositionsTest() throws Exception {
public void getTest() throws Exception {
System.out.print("-> get() - ");

assertNotNull(shoppingCartDAO.get());
assertNotNull(shoppingCartRepository.get());

System.out.println("OK!");
}
Expand All @@ -115,13 +115,13 @@ public void getTest() throws Exception {
public void getSizeTest() throws Exception {
System.out.print("-> getSize() - ");

assertTrue(shoppingCartDAO.getSize() == 0);
assertTrue(shoppingCartRepository.getSize() == 0);

Product product = new Product("Title", "URL", null, null, 10.0);
SalePosition position = new SalePosition(product, 2);
shoppingCartDAO.addSalePosition(position);
shoppingCartRepository.addSalePosition(position);

assertTrue(shoppingCartDAO.getSize() == 2);
assertTrue(shoppingCartRepository.getSize() == 2);

System.out.println("OK!");
}
Expand All @@ -130,13 +130,13 @@ public void getSizeTest() throws Exception {
public void getPriceTest() throws Exception {
System.out.print("-> getPrice() - ");

assertTrue(shoppingCartDAO.getPrice() == 0);
assertTrue(shoppingCartRepository.getPrice() == 0);

Product product = new Product("Title", "URL", null, null, 10.0);
SalePosition position = new SalePosition(product, 2);
shoppingCartDAO.addSalePosition(position);
shoppingCartRepository.addSalePosition(position);

assertTrue(shoppingCartDAO.getPrice() == position.getPrice());
assertTrue(shoppingCartRepository.getPrice() == position.getPrice());

System.out.println("OK!");
}
Expand Down
Loading

0 comments on commit a53af97

Please sign in to comment.