Skip to content

Exam hand in for the Backend-programming course fall 2023

Notifications You must be signed in to change notification settings

felixbyrjall/backend-exam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

PGR209 - Backendprogramming exam

Candidate numbers:
2014
2006

Getting started:

- Run 'MachineFactoryApplication.java'
- The application runs on 'http://localhost:8080'
- Use Postman or any other API platform to send requests
- Please use the provided json-templates in “TEMPLATES.txt”, for PUT and POST requests.
   All requests are also showcased in our endpoint tests.

To run all tests, you can either:

- Right-click java folder under the ‘test’ folder and Run tests
- Run ‘mvn test’ in terminal from ‘..\machine-factory’. (‘cd machine-factory’)
- Run each class file or test method individually.

Project information:

- All features, business logic and rules are showcased and thoroughly tested in our tests.
- An overview over the highlighted features, business logic and rules are described below.
- We’ve made a service file named ‘DataFeedService’ to initialize sample data using our applications logic,
   following the order of how everything is created, saved and set.

API:

/api/order
/api/customer
/api/address
/api/machine
/api/subassembly
/api/part

All APIs have implemented the following METHODS:

GET                               -> returns all entities of a specific domain
GET /{id}                       -> returns an entity by id
GET /page/{pageNr}    -> returns all entities on a specific page
POST                             -> creates an entity of a specific domain
DELETE /{id}                 -> deletes an entity by id
PUT /{id}                       -> updates an entity by id

Besides implementing all required features, here’s our additional features:

- Create a customer, and add an address to it.
- Create an address and add it to a customer.
- Add an address to a customer.
- Added controlled responses for all requests to the API endpoints.
- Implemented DTOs for all models.
- Deleting a machine, deletes all orders containing that machine.
- Deleting a part or subassembly sets fields containing those
   entities to null before deleting the part or subassembly.
- The user can update machine with an empty subassemblyId,
   but gets an error even if the field contains just one id that doesn't exist in the subassembly table.
- The user can update subassembly with an empty partId,
   but gets an error even if the field contains just one id that doesn't exist in the part table.
- Besides the required tests, we also made unit tests for the repositories
- Implemented ActiveProfiles for more controlled testing environments

Logic / relationship

Deleting an Order, deletes the whole order, but the customer, while the address and machine will still exist in their own tables.

Deleting a Customer, deletes the customer and the order(if there is any), while the address will still exist in its own table.

Deleting an Address, deletes the address and the order(if there is any), while the customer will still exist in its own table.

Deleting a Machine, deletes all orders containing the machine, then deletes the machine.

Deleting a Subassembly, sets the subassemblyId field in all machines containing that subassemblyId to null, then deletes the subassembly.

Deleting a Part, sets the partId field in all subassemblies containing that partId to null, then deletes the part.

Rules:

Before creating an order, the customer, address and machine(s) must be created(if they don't already exist).
Then create an order with the correct ids associated.

Machines, subassemblies and parts can be created separately.
They can be connected by adding the associated ids upon creation or when updating.

The same goes for the relationship between customers and addresses.

Sources:

- Associated lectures and course material in course PGR209, autumn 2023

Spring Boot and Spring Data JPA:

- https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/ResponseEntity.html
   (Referred and accessed in December, 2023)
- https://www.baeldung.com/java-dto-pattern#2-connecting-both-sides
   (Referred and accessed in December, 2023)
- https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/HttpHeaders.html
   (Referred and accessed in December, 2023)
- https://www.geeksforgeeks.org/stream-anymatch-java-examples/
   (Referred and accessed in December, 2023)
- https://www.baeldung.com/java-optional-uses
   (Referred and accessed in December, 2023)

Database, H2 and entities:

- https://www.h2database.com/html/tutorial.html
   (Referred and accessed in December, 2023)
- https://www.baeldung.com/jpa-cascade-types
   (Referred and accessed in December, 2023)
- https://www.geeksforgeeks.org/spring-boot-h2-database/
   (Referred and accessed in December, 2023)

Mock and testing:

- https://docs.spring.io/spring-framework/reference/testing.html
   (Referred and accessed in December, 2023)
- https://docs.spring.io/spring-framework/reference/testing/annotations/integration-spring/annotation-activeprofiles.html
   (Referred and accessed in December, 2023)
- https://docs.spring.io/spring-framework/reference/testing/spring-mvc-test-framework/vs-end-to-end-integration-tests.html
   (Referred and accessed in December, 2023)
- https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing
   (Referred and accessed in December, 2023)
- https://www.baeldung.com/maven-run-single-test
   (Referred and accessed in December, 2023)
- https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/MediaType.html
   (Referred and accessed in December, 2023)
- https://docs.spring.io/spring-framework/reference/data-access/transaction/declarative/annotations.html
   (Referred and accessed in December, 2023)

Github repositories from lectures:

- https://github.com/jlwcrews2/vet-clinic
   (Referred and accessed in December, 2023)
- https://github.com/jlwcrews2/jpa-demo
   (Referred and accessed in December, 2023)

About

Exam hand in for the Backend-programming course fall 2023

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages