Final test - #2
Open
Nick040791 wants to merge 16 commits into
Open
Conversation
- Created MySQL 'web_shop' server running on port 3306 - Configured spring.datasource user/pass
1. Loaded/ran 'create-database.sql' script in My SQL workbench successfully serving over port 3306 2. Test ran Spring Boor Application in IntelliJ 3. Postman collections loaded from import into workspace 3. Ran POST login to authenticate as Admin 4. Ran Profile and User REST endpoint requests with success. using Postman *Read for exercises*
-OrderController.java -OrderItemController.java -ProdcutController.java
Created the Product DAO class, fixed capitalization issues and ran the spring boot application. implemented: get create update delete tests never reach the DAO because there is no ProductController yet.
implemented Product Controller for Product DAO get create update delete -all ProductEndpointTests unit tests pass -all Postman Products API endpoint tests pass
implemented the Order Data Access Object with: list order, list order by username, get order by id, create order,
OrderController for OrderDao implemented: list, get, create, update, delete, controls units tests pass for OrderEndpointTests, ProductsEndpointTests, and UserEndpointTests Postman API endpoint tests pass for Orders other than update order --
updated OrderItemDao class with list list order get by id create update delete -- cannot test without controller
Completed OrderByItemController - all unit tests pass - all postman endpoint tests pass Unit 2 complete!
-changed project settings to JDK 17 - removed java 25 compiler plugin from pom.xl
clear sensitive credentials set to placeholder values
There was a problem hiding this comment.
Pull request overview
This PR adds basic CRUD data-access + REST endpoints for products, orders, and order items in the Spring Boot app, along with a Postman workspace/collection export and several IDE project files.
Changes:
- Added
ProductDao/OrderDao/OrderItemDaoand corresponding controllers under/api/products,/api/orders, and/api/order-items. - Added Postman request YAMLs for login/profile/users/products/orders/order-items.
- Updated DB credentials in
application.propertiesand added IntelliJ.ideaproject/datasource files.
Reviewed changes
Copilot reviewed 44 out of 60 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| java-springboot-final/src/main/resources/application.properties | Updates datasource username/password. |
| java-springboot-final/src/main/java/org/example/daos/ProductDao.java | Adds JDBC-based DAO for products. |
| java-springboot-final/src/main/java/org/example/daos/OrderItemDao.java | Adds JDBC-based DAO for order_items. |
| java-springboot-final/src/main/java/org/example/daos/OrderDao.java | Adds JDBC-based DAO for orders. |
| java-springboot-final/src/main/java/org/example/controllers/ProductController.java | Adds REST CRUD endpoints for products. |
| java-springboot-final/src/main/java/org/example/controllers/OrderItemController.java | Adds REST CRUD endpoints for order items (incl. optional orderId filter). |
| java-springboot-final/src/main/java/org/example/controllers/OrderController.java | Adds REST CRUD endpoints for orders (incl. optional username filter, and Principal overwrite on POST). |
| java-springboot-final/postman/postman/globals/workspace.globals.yaml | Adds Postman globals scaffold. |
| java-springboot-final/postman/postman/collections/web-store/Users/Get Test User.request.yaml | Adds Postman request for fetching test user. |
| java-springboot-final/postman/postman/collections/web-store/Users/Get Test User Roles.request.yaml | Adds Postman request for fetching test user roles. |
| java-springboot-final/postman/postman/collections/web-store/Users/Get All Users.request.yaml | Adds Postman request for listing users. |
| java-springboot-final/postman/postman/collections/web-store/Users/Delete Test User.request.yaml | Adds Postman request for deleting test user. |
| java-springboot-final/postman/postman/collections/web-store/Users/Delete TEST role from test.request.yaml | Adds Postman request for deleting a role from test user. |
| java-springboot-final/postman/postman/collections/web-store/Users/Create Test User.request.yaml | Adds Postman request for creating test user. |
| java-springboot-final/postman/postman/collections/web-store/Users/Change Test Password.request.yaml | Adds Postman request for changing test user password. |
| java-springboot-final/postman/postman/collections/web-store/Users/Add TEST role to test.request.yaml | Adds Postman request for adding TEST role. |
| java-springboot-final/postman/postman/collections/web-store/Users/Add ADMIN role to test.request.yaml | Adds Postman request for adding ADMIN role. |
| java-springboot-final/postman/postman/collections/web-store/Users/.resources/definition.yaml | Adds Postman collection metadata for Users folder. |
| java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile.request.yaml | Adds Postman request for profile. |
| java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile Roles.request.yaml | Adds Postman request for profile roles. |
| java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -test-.request.yaml | Adds Postman request to change password to “test”. |
| java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -admin-.request.yaml | Adds Postman request to change password to “admin”. |
| java-springboot-final/postman/postman/collections/web-store/Profile/.resources/definition.yaml | Adds Postman collection metadata for Profile folder. |
| java-springboot-final/postman/postman/collections/web-store/Products/Update Product 6.request.yaml | Adds Postman request for updating a product. |
| java-springboot-final/postman/postman/collections/web-store/Products/Get Product By Id.request.yaml | Adds Postman request for product by id. |
| java-springboot-final/postman/postman/collections/web-store/Products/Get All Products.request.yaml | Adds Postman request for listing products. |
| java-springboot-final/postman/postman/collections/web-store/Products/Delete Product 6.request.yaml | Adds Postman request for deleting a product. |
| java-springboot-final/postman/postman/collections/web-store/Products/Create Product 6.request.yaml | Adds Postman request for creating a product. |
| java-springboot-final/postman/postman/collections/web-store/Products/.resources/definition.yaml | Adds Postman collection metadata for Products folder. |
| java-springboot-final/postman/postman/collections/web-store/Orders/Update Order 6.request.yaml | Adds Postman request for updating an order. |
| java-springboot-final/postman/postman/collections/web-store/Orders/Get Order By Id.request.yaml | Adds Postman request for order by id. |
| java-springboot-final/postman/postman/collections/web-store/Orders/Get All Orders.request.yaml | Adds Postman request for listing orders. |
| java-springboot-final/postman/postman/collections/web-store/Orders/Delete Order 6.request.yaml | Adds Postman request for deleting an order. |
| java-springboot-final/postman/postman/collections/web-store/Orders/Create Order 6.request.yaml | Adds Postman request for creating an order. |
| java-springboot-final/postman/postman/collections/web-store/Orders/.resources/definition.yaml | Adds Postman collection metadata for Orders folder. |
| java-springboot-final/postman/postman/collections/web-store/Order Items/Update Order Item 1.request.yaml | Adds Postman request for updating an order item. |
| java-springboot-final/postman/postman/collections/web-store/Order Items/Get Order Item By Id.request.yaml | Adds Postman request for order item by id. |
| java-springboot-final/postman/postman/collections/web-store/Order Items/Get All Order Items.request.yaml | Adds Postman request for listing order items. |
| java-springboot-final/postman/postman/collections/web-store/Order Items/Delete Order Item 1.request.yaml | Adds Postman request for deleting an order item. |
| java-springboot-final/postman/postman/collections/web-store/Order Items/Create Order Item 1.request.yaml | Adds Postman request for creating an order item. |
| java-springboot-final/postman/postman/collections/web-store/Order Items/.resources/definition.yaml | Adds Postman collection metadata for Order Items folder. |
| java-springboot-final/postman/postman/collections/web-store/login.request.yaml | Adds Postman login request + token capture script. |
| java-springboot-final/postman/postman/collections/web-store/.resources/definition.yaml | Adds Postman collection root metadata/variables/auth. |
| java-springboot-final/postman/.postman/resources.yaml | Adds Postman workspace resource mapping. |
| java-springboot-final/pom.xml | Whitespace-only change. |
| java-springboot-final/.idea/sqldialects.xml | Adds IntelliJ SQL dialect mapping. |
| java-springboot-final/.idea/misc.xml | Adds IntelliJ project JDK/language level config. |
| java-springboot-final/.idea/dataSources/data_sources_history.xml | Adds IntelliJ datasource history (local). |
| java-springboot-final/.idea/dataSources.xml | Adds IntelliJ datasource config. |
| java-springboot-final/.idea/dataSources.local.xml | Adds IntelliJ local datasource config (local). |
| java-springboot-final/.idea/data_source_mapping.xml | Adds IntelliJ datasource-per-file mapping. |
| .idea/vcs.xml | Adds IntelliJ VCS mapping for repo root. |
| .idea/modules.xml | Adds IntelliJ module list for repo root. |
| .idea/misc.xml | Adds IntelliJ project config for repo root. |
| .idea/jarRepositories.xml | Adds IntelliJ Maven repo config for repo root. |
| .idea/flexpath-unit-2-final.iml | Adds IntelliJ module file for repo root. |
| .idea/encodings.xml | Adds IntelliJ encoding settings for repo root. |
| .idea/dataSources.xml | Adds IntelliJ datasource config for repo root. |
| .idea/compiler.xml | Adds IntelliJ compiler settings for repo root. |
| .idea/.gitignore | Adds IntelliJ-local ignore rules under .idea/. |
Files not reviewed (15)
- .idea/.gitignore: Generated file
- .idea/compiler.xml: Generated file
- .idea/dataSources.xml: Generated file
- .idea/encodings.xml: Generated file
- .idea/flexpath-unit-2-final.iml: Generated file
- .idea/jarRepositories.xml: Generated file
- .idea/misc.xml: Generated file
- .idea/modules.xml: Generated file
- .idea/vcs.xml: Generated file
- java-springboot-final/.idea/dataSources.local.xml: Generated file
- java-springboot-final/.idea/dataSources.xml: Generated file
- java-springboot-final/.idea/dataSources/data_sources_history.xml: Generated file
- java-springboot-final/.idea/data_source_mapping.xml: Generated file
- java-springboot-final/.idea/misc.xml: Generated file
- java-springboot-final/.idea/sqldialects.xml: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+2
to
+3
| spring.datasource.username=nick0 | ||
| spring.datasource.password=Nb221291?? |
Comment on lines
+43
to
+47
| public Product createProduct(Product product) { | ||
| String sql = "INSERT INTO products (name, price) VALUES (?,?)"; | ||
| jdbcTemplate.update(sql, product.getName(), product.getPrice()); | ||
| return jdbcTemplate.queryForObject("SELECT * FROM products WHERE id = LAST_INSERT_ID();", this::mapToProduct); | ||
| } |
Comment on lines
+37
to
+43
| public Order createOrder(Order order) { | ||
| String sql = "INSERT INTO orders (username) VALUES (?);"; | ||
| jdbcTemplate.update(sql, order.getUsername()); | ||
| return jdbcTemplate.queryForObject( | ||
| "SELECT * FROM orders WHERE id = LAST_INSERT_ID();", | ||
| this::mapToOrder); | ||
| } |
Comment on lines
+37
to
+44
| public OrderItem createOrderItem(OrderItem item) { | ||
| String sql = "INSERT INTO order_items (order_id, product_id, quantity) VALUES (?, ?, ?);"; | ||
| jdbcTemplate.update(sql, | ||
| item.getOrderId(), item.getProductId(), item.getQuantity()); | ||
| return jdbcTemplate.queryForObject( | ||
| "SELECT * FROM order_items WHERE id = LAST_INSERT_ID();", | ||
| this::mapToOrderItem); | ||
| } |
Comment on lines
+37
to
+41
| try { | ||
| return productDao.updateProduct(product); | ||
| } catch (RuntimeException e) { | ||
| throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Product not found"); | ||
| } |
Comment on lines
+40
to
+44
| try { | ||
| return orderItemDao.updateOrderItem(item); | ||
| } catch (RuntimeException e) { | ||
| throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Order item not found"); | ||
| } |
Comment on lines
+51
to
+55
| try { | ||
| return orderDao.updateOrder(order); | ||
| } catch (RuntimeException e) { | ||
| throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Order not found"); | ||
| } |
Comment on lines
+8
to
+18
| <remarks>C:/Users/nicho/OneDrive/Documents/GitHub/flexpath-unit-2-final/java-springboot-final/src/main/resources/application.properties</remarks> | ||
| <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver> | ||
| <jdbc-url>jdbc:mysql://localhost:3306/web_shop</jdbc-url> | ||
| <jdbc-additional-properties> | ||
| <property name="com.intellij.clouds.kubernetes.db.host.port" /> | ||
| <property name="com.intellij.clouds.kubernetes.db.enabled" value="false" /> | ||
| <property name="com.intellij.clouds.kubernetes.db.container.port" /> | ||
| </jdbc-additional-properties> | ||
| <secret-storage>master_key</secret-storage> | ||
| <user-name>nick0</user-name> | ||
| <schema-mapping /> |
Comment on lines
+3
to
+9
| <component name="dataSourceStorageLocal" created-in="IU-262.8665.258"> | ||
| <data-source name="web_shop@localhost" uuid="85733b47-5a05-4bc1-95af-19085e761aa9"> | ||
| <database-info product="" version="" jdbc-version="" driver-name="" driver-version="" dbms="MYSQL" /> | ||
| <secret-storage>master_key</secret-storage> | ||
| <user-name>nick0</user-name> | ||
| <schema-mapping /> | ||
| </data-source> |
| } | ||
| } | ||
|
|
||
| //Postman gets 404 because there is no order 6 No newline at end of file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.