-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 837e14f
Showing
18 changed files
with
1,412 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
HELP.md | ||
target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Critter Chronologer Project Starter | ||
|
||
Critter Chronologer a Software as a Service application that provides a scheduling interface for a small business that takes care of animals. This Spring Boot project will allow users to create pets, owners, and employees, and then schedule events for employees to provide services for pets. | ||
|
||
|
||
## Getting Started | ||
|
||
### Dependencies | ||
|
||
* [IntelliJ IDEA Community Edition](https://www.jetbrains.com/idea/download) (or Ultimate) recommended | ||
* [Java SE Development Kit 8+](https://www.oracle.com/technetwork/java/javase/downloads/index.html) | ||
* [Maven](https://maven.apache.org/download.cgi) | ||
* [MySQL Server 8](https://dev.mysql.com/downloads/mysql/) (or another standalone SQL instance) | ||
* [Postman](https://www.getpostman.com/downloads/) | ||
|
||
Part of this project involves configuring a Spring application to connect to an external data source. Before beginning this project, you must install a database to connect to. Here are [instructions for installing MySQL 8](https://dev.mysql.com/doc/refman/8.0/en/installing.html). | ||
|
||
You should install the Server and Connector/J, but it is also convenient to install the Documentation and Workbench. | ||
|
||
Alternately, you may wish to run MySQL in a docker container, using [these instructions](https://hub.docker.com/_/mysql/). | ||
|
||
After installing the Server, you will need to create a user that your application will use to perform operations on the server. You should create a user that has all permissions on localhost using the sql command found [here](https://dev.mysql.com/doc/refman/8.0/en/creating-accounts.html). | ||
|
||
Another SQL database may be used if desired, but do not use the H2 in-memory database as your primary datasource. | ||
|
||
### Installation | ||
|
||
1. Clone or download this repository. | ||
2. Open IntelliJ IDEA. | ||
3. In IDEA, select `File` -> `Open` and navigate to the `critter` directory within this repository. Select that directory to open. | ||
4. The project should open in IDEA. In the project structure, navigate to `src/main/java/com.udacity.jdnd.course3.critter`. | ||
5. Within that directory, click on CritterApplication.java and select `Run` -> `Debug CritterApplication`. | ||
6. Open a browser and navigate to the url: [http://localhost:8082/test](http://localhost:8082/test) | ||
|
||
You should see the message "Critter Starter installed successfully" in your browser. | ||
|
||
## Testing | ||
|
||
Once you have completed the above installation, you should also be able to run the included unit tests to verify basic functionality as you complete it. To run unit tests: | ||
|
||
1. Within your project in IDEA, Navigate to `src/test/java/com.udacity.jdnd.course3.critter`. | ||
2. Within that directory, click on `CritterFunctionalTest.java` and select `Run` -> `Run CritterFunctionalTest`. | ||
|
||
A window should open showing you the test executions. All 9 tests should fail and if you click on them they will show `java.lang.UnsupportedOperationeException` as the cause. | ||
|
||
As you complete the objectives of this project, you will be able to verify progress by re-running these tests. | ||
|
||
### Tested Conditions | ||
Tests will pass under the following conditions: | ||
|
||
* `testCreateCustomer` - **UserController.saveCustomer** returns a saved customer matching the request | ||
* `testCreateEmployee` - **UserController.saveEmployee** returns a saved employee matching the request | ||
* `testAddPetsToCustomer` - **PetController.getPetsByOwner** returns a saved pet with the same id and name as the one saved with **UserController.savePet** for a given owner | ||
* `testFindPetsByOwner` - **PetController.getPetsByOwner** returns all pets saved for that owner. | ||
* `testFindOwnerByPet` - **UserController.getOwnerByPet** returns the saved owner used to create the pet. | ||
* `testChangeEmployeeAvailability` - **UserController.getEmployee** returns an employee with the same availability as set for that employee by **UserControler.setAvailability** | ||
* `testFindEmployeesByServiceAndTime` - **UserController.findEmployeesForService** returns all saved employees that have the requested availability and skills and none that do not | ||
* `testSchedulePetsForServiceWithEmployee` - **ScheduleController.createSchedule** returns a saved schedule matching the requested activities, pets, employees, and date | ||
* `testFindScheduleByEntities` - **ScheduleController.getScheduleForEmployee** returns all saved schedules containing that employee. **ScheduleController.getScheduleForPet** returns all saved schedules for that pet. **ScheduleController.getScheduleForCustomer** returns all saved schedules for any pets belonging to that owner. | ||
|
||
### Postman | ||
In addition to the included unit tests, a Postman collection has been provided. | ||
|
||
1. Open Postman. | ||
2. Select the `Import` button. | ||
3. Import the file found in this repository under `src/main/resource/Udacity.postman_collection.json` | ||
4. Expand the Udacity folder in postman. | ||
|
||
Each entry in this collection contains information in its `Body` tab if necessary and all requests should function for a completed project. Depending on your key generation strategy, you may need to edit the specific ids in these requests for your particular project. | ||
|
||
## Built With | ||
|
||
* [Spring Boot](https://spring.io/projects/spring-boot) - Framework providing dependency injection, web framework, data binding, resource management, transaction management, and more. | ||
* [Google Guava](https://github.com/google/guava) - A set of core libraries used in this project for their collections utilities. | ||
* [H2 Database Engine](https://www.h2database.com/html/main.html) - An in-memory database used in this project to run unit tests. | ||
* [MySQL Connector/J](https://www.mysql.com/products/connector/) - JDBC Drivers to allow Java to connect to MySQL Server | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE.md]() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.2.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.udacity.jdnd.course3</groupId> | ||
<artifactId>critter</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>critter</name> | ||
<description>Starter code for Critter Chronologer project</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jdbc</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>28.1-jre</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/udacity/jdnd/course3/critter/CritterApplication.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.udacity.jdnd.course3.critter; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* Launches the Spring application. Unmodified from starter code. | ||
*/ | ||
@SpringBootApplication | ||
public class CritterApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(CritterApplication.class, args); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/udacity/jdnd/course3/critter/CritterController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.udacity.jdnd.course3.critter; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* Dummy controller class to verify installation success. Do not use for | ||
* your project work. | ||
*/ | ||
@RestController | ||
public class CritterController { | ||
|
||
@GetMapping("/test") | ||
public String test(){ | ||
return "Critter Starter installed successfully"; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/udacity/jdnd/course3/critter/pet/PetController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.udacity.jdnd.course3.critter.pet; | ||
|
||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Handles web requests related to Pets. | ||
*/ | ||
@RestController | ||
@RequestMapping("/pet") | ||
public class PetController { | ||
|
||
@PostMapping | ||
public PetDTO savePet(@RequestBody PetDTO petDTO) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@GetMapping("/{petId}") | ||
public PetDTO getPet(@PathVariable long petId) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@GetMapping | ||
public List<PetDTO> getPets(){ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@GetMapping("/owner/{ownerId}") | ||
public List<PetDTO> getPetsByOwner(@PathVariable long ownerId) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/udacity/jdnd/course3/critter/pet/PetDTO.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.udacity.jdnd.course3.critter.pet; | ||
|
||
import java.time.LocalDate; | ||
|
||
/** | ||
* Represents the form that pet request and response data takes. Does not map | ||
* to the database directly. | ||
*/ | ||
public class PetDTO { | ||
private long id; | ||
private PetType type; | ||
private String name; | ||
private long ownerId; | ||
private LocalDate birthDate; | ||
private String notes; | ||
|
||
public PetType getType() { | ||
return type; | ||
} | ||
|
||
public void setType(PetType type) { | ||
this.type = type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public long getOwnerId() { | ||
return ownerId; | ||
} | ||
|
||
public void setOwnerId(long ownerId) { | ||
this.ownerId = ownerId; | ||
} | ||
|
||
public LocalDate getBirthDate() { | ||
return birthDate; | ||
} | ||
|
||
public void setBirthDate(LocalDate birthDate) { | ||
this.birthDate = birthDate; | ||
} | ||
|
||
public String getNotes() { | ||
return notes; | ||
} | ||
|
||
public void setNotes(String notes) { | ||
this.notes = notes; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/udacity/jdnd/course3/critter/pet/PetType.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.udacity.jdnd.course3.critter.pet; | ||
|
||
/** | ||
* A example list of pet type metadata that could be included on a request to create a pet. | ||
*/ | ||
public enum PetType { | ||
CAT, DOG, LIZARD, BIRD, FISH, SNAKE, OTHER; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/udacity/jdnd/course3/critter/schedule/ScheduleController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.udacity.jdnd.course3.critter.schedule; | ||
|
||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Handles web requests related to Schedules. | ||
*/ | ||
@RestController | ||
@RequestMapping("/schedule") | ||
public class ScheduleController { | ||
|
||
@PostMapping | ||
public ScheduleDTO createSchedule(@RequestBody ScheduleDTO scheduleDTO) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@GetMapping | ||
public List<ScheduleDTO> getAllSchedules() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@GetMapping("/pet/{petId}") | ||
public List<ScheduleDTO> getScheduleForPet(@PathVariable long petId) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@GetMapping("/employee/{employeeId}") | ||
public List<ScheduleDTO> getScheduleForEmployee(@PathVariable long employeeId) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@GetMapping("/customer/{customerId}") | ||
public List<ScheduleDTO> getScheduleForCustomer(@PathVariable long customerId) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
Oops, something went wrong.