Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

A student that completes this project shows they can:

* explain what automated testing is and why it is important
* use JUnit to write, run, and interpret the output of unit tests for services with or without database access
* use JUnit to write, run, and interpret the output of unit tests for controllers
* implement Automated Integration Testing for REST APIs using JUnit and RestAssured
- explain what automated testing is and why it is important
- use JUnit to write, run, and interpret the output of unit tests for services with or without database access
- use JUnit to write, run, and interpret the output of unit tests for controllers
- implement Automated Integration Testing for REST APIs using JUnit and RestAssured

## Introduction

Expand All @@ -15,9 +15,9 @@ This is a basic database scheme with users, user emails, and user roles. This Ja

The data layout is as follows

* User is the driving table.
* Useremails have a Many-To-One relationship with User. Each User has many user email combinations. Each user email combination has only one User.
* Roles have a Many-To-Many relationship with Users.
- User is the driving table.
- Useremails have a Many-To-One relationship with User. Each User has many user email combinations. Each user email combination has only one User.
- Roles have a Many-To-Many relationship with Users.

![Image of Database Layout](usersfinaldb.png)

Expand Down Expand Up @@ -2345,14 +2345,14 @@ Status 201 Created

## Instructions

* [ ] Please fork and clone this repository.
* [ ] This repository does have a starter project, so you must start with that application inside of the cloned repository folder. Regularly commit and push your code as appropriate.
- [ ] Please fork and clone this repository.
- [ ] This repository does have a starter project, so you must start with that application inside of the cloned repository folder. Regularly commit and push your code as appropriate.

### MVP

* [ ] Provide unit testing for the User Service. To reach MVP you must provide at least 75% coverage of the code in User Service as reported in IntelliJ
* [ ] Provide unit testing for the User Controller. To reach MVP you must provide at least 75% coverage of the code in User Controller as reported in IntelliJ
- [ ] Provide unit testing for the User Service. To reach MVP you must provide at least 75% coverage of the code in User Service as reported in IntelliJ
- [ ] Provide unit testing for the User Controller. To reach MVP you must provide at least 75% coverage of the code in User Controller as reported in IntelliJ

### Stretch Goal

* [ ] Provide integration testing for the User Controller. To reach MVP you must provide at least 75% coverage of the code in User Controller as reported in IntelliJ
- [ ] Provide integration testing for the User Controller. To reach MVP you must provide at least 75% coverage of the code in User Controller as reported in IntelliJ
178 changes: 89 additions & 89 deletions usermodel-initial/.mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,103 +26,103 @@ Licensed to the Apache Software Foundation (ASF) under one
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;

public class MavenWrapperDownloader
{
public class MavenWrapperDownloader {
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";

/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println(
"- Using base directory: " + baseDirectory.getAbsolutePath()
);

public static void main(String args[])
{
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists())
{
FileInputStream mavenWrapperPropertyFileInputStream = null;
try
{
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
}
catch (IOException e)
{
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
}
finally
{
try
{
if (mavenWrapperPropertyFileInputStream != null)
{
mavenWrapperPropertyFileInputStream.close();
}
}
catch (IOException e)
{
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists())
{
if (!outputFile.getParentFile().mkdirs())
{
System.out.println("- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try
{
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
}
catch (Throwable e)
{
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(
baseDirectory,
MAVEN_WRAPPER_PROPERTIES_PATH
);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream =
new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url =
mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println(
"- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"
);
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);

private static void downloadFileFromURL(String urlString, File destination) throws Exception
{
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
File outputFile = new File(
baseDirectory.getAbsolutePath(),
MAVEN_WRAPPER_JAR_PATH
);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" +
outputFile.getParentFile().getAbsolutePath() +
"'"
);
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination)
throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
17 changes: 8 additions & 9 deletions usermodel-initial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ This is a basic database scheme with users, user emails, and user roles. This Ja

The table layout is similar to the initial version with the following exceptions:

* The join table userroles is explicitly created. This allows us to add additional columns to the join table
* Since we are creating the join table ourselves, the Many to Many relationship that formed the join table is now two Many to One relationships
* All tables now have audit fields
- The join table userroles is explicitly created. This allows us to add additional columns to the join table
- Since we are creating the join table ourselves, the Many to Many relationship that formed the join table is now two Many to One relationships
- All tables now have audit fields

Thus the new table layout is as follows

* User is the driving table.
* Useremails have a Many-To-One relationship with User. Each User has many user email combinations. Each user email combination has only one User.
* Roles have a Many-To-Many relationship with Users.
- User is the driving table.
- Useremails have a Many-To-One relationship with User. Each User has many user email combinations. Each user email combination has only one User.
- Roles have a Many-To-Many relationship with Users.

![Image of Database Layout](usersfinaldb.png)

Expand Down Expand Up @@ -218,7 +218,6 @@ Status OK

</details>


<details>
<summary>PUT http://localhost:2019/useremails/useremail/9/email/favbun@hops.local</summary>

Expand Down Expand Up @@ -876,12 +875,12 @@ DATA
}
],
"roles": [
{
{
"role": {
"roleid": 3
}
},
{
{
"role": {
"roleid": 1
}
Expand Down
Loading