Zavon Malone 5 years ago
parent
commit
0d4c68b0b9

+ 63
- 2
mvnw View File

@@ -108,7 +108,7 @@ if $cygwin ; then
108 108
     CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 109
 fi
110 110
 
111
-# For Migwn, ensure paths are in UNIX format before anything is touched
111
+# For Mingw, ensure paths are in UNIX format before anything is touched
112 112
 if $mingw ; then
113 113
   [ -n "$M2_HOME" ] &&
114 114
     M2_HOME="`(cd "$M2_HOME"; pwd)`"
@@ -200,8 +200,69 @@ if [ -z "$BASE_DIR" ]; then
200 200
   exit 1;
201 201
 fi
202 202
 
203
+##########################################################################################
204
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
205
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
206
+##########################################################################################
207
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
208
+    if [ "$MVNW_VERBOSE" = true ]; then
209
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
210
+    fi
211
+else
212
+    if [ "$MVNW_VERBOSE" = true ]; then
213
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
214
+    fi
215
+    jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
216
+    while IFS="=" read key value; do
217
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
218
+      esac
219
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
220
+    if [ "$MVNW_VERBOSE" = true ]; then
221
+      echo "Downloading from: $jarUrl"
222
+    fi
223
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
224
+
225
+    if command -v wget > /dev/null; then
226
+        if [ "$MVNW_VERBOSE" = true ]; then
227
+          echo "Found wget ... using wget"
228
+        fi
229
+        wget "$jarUrl" -O "$wrapperJarPath"
230
+    elif command -v curl > /dev/null; then
231
+        if [ "$MVNW_VERBOSE" = true ]; then
232
+          echo "Found curl ... using curl"
233
+        fi
234
+        curl -o "$wrapperJarPath" "$jarUrl"
235
+    else
236
+        if [ "$MVNW_VERBOSE" = true ]; then
237
+          echo "Falling back to using Java to download"
238
+        fi
239
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
240
+        if [ -e "$javaClass" ]; then
241
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
242
+                if [ "$MVNW_VERBOSE" = true ]; then
243
+                  echo " - Compiling MavenWrapperDownloader.java ..."
244
+                fi
245
+                # Compiling the Java class
246
+                ("$JAVA_HOME/bin/javac" "$javaClass")
247
+            fi
248
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
249
+                # Running the downloader
250
+                if [ "$MVNW_VERBOSE" = true ]; then
251
+                  echo " - Running MavenWrapperDownloader.java ..."
252
+                fi
253
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
254
+            fi
255
+        fi
256
+    fi
257
+fi
258
+##########################################################################################
259
+# End of extension
260
+##########################################################################################
261
+
203 262
 export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204
-echo $MAVEN_PROJECTBASEDIR
263
+if [ "$MVNW_VERBOSE" = true ]; then
264
+  echo $MAVEN_PROJECTBASEDIR
265
+fi
205 266
 MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 267
 
207 268
 # For Cygwin, switch paths to Windows format before running java

+ 19
- 1
mvnw.cmd View File

@@ -35,6 +35,8 @@
35 35
 
36 36
 @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 37
 @echo off
38
+@REM set title of command window
39
+title %0
38 40
 @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 41
 @if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
40 42
 
@@ -115,10 +117,26 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s
115 117
 :endReadAdditionalConfig
116 118
 
117 119
 SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118
-
119 120
 set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 121
 set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 122
 
123
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
124
+FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
125
+	IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 
126
+)
127
+
128
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
129
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
130
+if exist %WRAPPER_JAR% (
131
+    echo Found %WRAPPER_JAR%
132
+) else (
133
+    echo Couldn't find %WRAPPER_JAR%, downloading it ...
134
+	echo Downloading from: %DOWNLOAD_URL%
135
+    powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
136
+    echo Finished downloading %WRAPPER_JAR%
137
+)
138
+@REM End of extension
139
+
122 140
 %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 141
 if ERRORLEVEL 1 goto error
124 142
 goto end

+ 52
- 23
pom.xml View File

@@ -2,21 +2,18 @@
2 2
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 3
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4 4
 	<modelVersion>4.0.0</modelVersion>
5
-
6
-	<groupId>io.zipcoder</groupId>
7
-	<artifactId>crud-app-starter</artifactId>
8
-	<version>0.0.1-SNAPSHOT</version>
9
-	<packaging>jar</packaging>
10
-
11
-	<name>crud-app-starter</name>
12
-	<description>Starter project for Spring Boot-based CRUD applications</description>
13
-
14 5
 	<parent>
15 6
 		<groupId>org.springframework.boot</groupId>
16 7
 		<artifactId>spring-boot-starter-parent</artifactId>
17
-		<version>1.5.2.RELEASE</version>
8
+		<version>1.5.19.BUILD-SNAPSHOT</version>
18 9
 		<relativePath/> <!-- lookup parent from repository -->
19 10
 	</parent>
11
+	<groupId>com.personcontroller</groupId>
12
+	<artifactId>demo</artifactId>
13
+	<version>0.0.1-SNAPSHOT</version>
14
+	<packaging>jar</packaging>
15
+	<name>demo</name>
16
+	<description>Demo project for Spring Boot</description>
20 17
 
21 18
 	<properties>
22 19
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -27,30 +24,24 @@
27 24
 	<dependencies>
28 25
 		<dependency>
29 26
 			<groupId>org.springframework.boot</groupId>
30
-			<artifactId>spring-boot-starter</artifactId>
27
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
28
+		</dependency>
29
+		<dependency>
30
+			<groupId>org.springframework.boot</groupId>
31
+			<artifactId>spring-boot-starter-web</artifactId>
31 32
 		</dependency>
32 33
 
33 34
 		<dependency>
34 35
 			<groupId>com.h2database</groupId>
35 36
 			<artifactId>h2</artifactId>
36
-            <scope>compile</scope>
37
+			<scope>runtime</scope>
37 38
 		</dependency>
38 39
 		<dependency>
39 40
 			<groupId>org.springframework.boot</groupId>
40 41
 			<artifactId>spring-boot-starter-test</artifactId>
41 42
 			<scope>test</scope>
42 43
 		</dependency>
43
-        <dependency>
44
-            <groupId>org.springframework.boot</groupId>
45
-            <artifactId>spring-boot-starter-web</artifactId>
46
-            <!--<version>RELEASE</version>-->
47
-        </dependency>
48
-		<dependency>
49
-			<groupId>org.springframework.boot</groupId>
50
-			<artifactId>spring-boot-starter-data-jpa</artifactId>
51
-			<!--<version>1.3.5.RELEASE</version>-->
52
-		</dependency>
53
-    </dependencies>
44
+	</dependencies>
54 45
 
55 46
 	<build>
56 47
 		<plugins>
@@ -61,5 +52,43 @@
61 52
 		</plugins>
62 53
 	</build>
63 54
 
55
+	<repositories>
56
+		<repository>
57
+			<id>spring-snapshots</id>
58
+			<name>Spring Snapshots</name>
59
+			<url>https://repo.spring.io/snapshot</url>
60
+			<snapshots>
61
+				<enabled>true</enabled>
62
+			</snapshots>
63
+		</repository>
64
+		<repository>
65
+			<id>spring-milestones</id>
66
+			<name>Spring Milestones</name>
67
+			<url>https://repo.spring.io/milestone</url>
68
+			<snapshots>
69
+				<enabled>false</enabled>
70
+			</snapshots>
71
+		</repository>
72
+	</repositories>
73
+
74
+	<pluginRepositories>
75
+		<pluginRepository>
76
+			<id>spring-snapshots</id>
77
+			<name>Spring Snapshots</name>
78
+			<url>https://repo.spring.io/snapshot</url>
79
+			<snapshots>
80
+				<enabled>true</enabled>
81
+			</snapshots>
82
+		</pluginRepository>
83
+		<pluginRepository>
84
+			<id>spring-milestones</id>
85
+			<name>Spring Milestones</name>
86
+			<url>https://repo.spring.io/milestone</url>
87
+			<snapshots>
88
+				<enabled>false</enabled>
89
+			</snapshots>
90
+		</pluginRepository>
91
+	</pluginRepositories>
92
+
64 93
 
65 94
 </project>

+ 12
- 0
src/main/java/com/personcontroller/demo/DemoApplication.java View File

@@ -0,0 +1,12 @@
1
+package com.personcontroller.demo;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+
6
+@SpringBootApplication
7
+public class DemoApplication {
8
+
9
+	public static void main(String[] args) {
10
+		SpringApplication.run(DemoApplication.class, args);
11
+	}
12
+}

+ 45
- 0
src/main/java/com/personcontroller/demo/Person.java View File

@@ -0,0 +1,45 @@
1
+package com.personcontroller.demo;
2
+
3
+import javax.persistence.Entity;
4
+import javax.persistence.GeneratedValue;
5
+import javax.persistence.GenerationType;
6
+import javax.persistence.Id;
7
+
8
+@Entity
9
+public class Person {
10
+
11
+    @Id
12
+    @GeneratedValue(strategy = GenerationType.AUTO)
13
+    private String firstName;
14
+    private String lastName;
15
+    private Integer id;
16
+
17
+
18
+    public Person() {
19
+
20
+    }
21
+
22
+    public String getFirstName() {
23
+        return firstName;
24
+    }
25
+
26
+    public void setFirstName(String firstName) {
27
+        this.firstName = firstName;
28
+    }
29
+
30
+    public String getLastName() {
31
+        return lastName;
32
+    }
33
+
34
+    public void setLastName(String lastName) {
35
+        this.lastName = lastName;
36
+    }
37
+
38
+    public Integer getId() {
39
+        return id;
40
+    }
41
+
42
+    public void setId(Integer id) {
43
+        this.id = id;
44
+    }
45
+}

+ 56
- 0
src/main/java/com/personcontroller/demo/PersonController.java View File

@@ -0,0 +1,56 @@
1
+package com.personcontroller.demo;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.http.HttpStatus;
5
+import org.springframework.http.ResponseEntity;
6
+import org.springframework.web.bind.annotation.*;
7
+
8
+
9
+@RestController
10
+public class PersonController {
11
+
12
+    @Autowired
13
+    PersonRepository personRepository;
14
+
15
+    @RequestMapping(value = "/people", method = RequestMethod.POST)
16
+    public ResponseEntity<Person> createPerson(@RequestBody Person p){
17
+
18
+        return new ResponseEntity<>(personRepository.save(p), HttpStatus.CREATED);
19
+    }
20
+
21
+    @RequestMapping(value = "/people{id}", method = RequestMethod.GET)
22
+    public ResponseEntity<Person> getPerson(@PathVariable Integer id){
23
+
24
+        Person p = personRepository.findOne(id);
25
+
26
+        if(p==null){
27
+            return new ResponseEntity<>(p, HttpStatus.NOT_FOUND);
28
+        }
29
+        return new ResponseEntity<>(p, HttpStatus.OK);
30
+    }
31
+
32
+    @RequestMapping(value = "/people", method = RequestMethod.GET)
33
+    public ResponseEntity<Iterable<Person>> getPersonList(){
34
+
35
+        return new ResponseEntity<>(personRepository.findAll(), HttpStatus.OK);
36
+    }
37
+
38
+    @RequestMapping(value = "/people{id}", method = RequestMethod.PUT)
39
+    public ResponseEntity<Person> updatePerson(@PathVariable Integer id, @RequestBody Person updatedPerson){
40
+
41
+        Person p = personRepository.findOne(id);
42
+
43
+        if(p!=null){
44
+            return new ResponseEntity<>(updatedPerson, HttpStatus.OK);
45
+        }
46
+            updatedPerson.setId(id);
47
+            personRepository.save(updatedPerson);
48
+        return new ResponseEntity<>(updatedPerson, HttpStatus.CREATED);
49
+    }
50
+
51
+    @RequestMapping(value = "/people", method = RequestMethod.DELETE)
52
+    public ResponseEntity<?> deletePerson(@PathVariable Integer id){
53
+        personRepository.delete(id);
54
+        return new ResponseEntity<>(null, HttpStatus.NO_CONTENT);
55
+    }
56
+}

+ 8
- 0
src/main/java/com/personcontroller/demo/PersonRepository.java View File

@@ -0,0 +1,8 @@
1
+package com.personcontroller.demo;
2
+
3
+import org.springframework.data.repository.CrudRepository;
4
+import org.springframework.stereotype.Repository;
5
+
6
+@Repository
7
+public interface PersonRepository extends CrudRepository<Person, Integer> {
8
+}

+ 0
- 22
src/main/java/io/zipcoder/crudapp/CRUDApplication.java View File

@@ -1,22 +0,0 @@
1
-package io.zipcoder.crudapp;
2
-
3
-import org.h2.server.web.WebServlet;
4
-import org.springframework.boot.SpringApplication;
5
-import org.springframework.boot.autoconfigure.SpringBootApplication;
6
-import org.springframework.boot.web.servlet.ServletRegistrationBean;
7
-import org.springframework.context.annotation.Bean;
8
-
9
-@SpringBootApplication
10
-public class CRUDApplication {
11
-
12
-	public static void main(String[] args) {
13
-		SpringApplication.run(CRUDApplication.class, args);
14
-	}
15
-
16
-	@Bean
17
-	ServletRegistrationBean h2servletRegistration(){
18
-		ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
19
-		registrationBean.addUrlMappings("/console/*");
20
-		return registrationBean;
21
-	}
22
-}

+ 0
- 4
src/main/resources/application-h2.properties View File

@@ -1,4 +0,0 @@
1
-spring.datasource.url=jdbc:h2:mem:testdb;Mode=Oracle
2
-spring.datasource.platform=h2
3
-spring.jpa.hibernate.ddl-auto=none
4
-spring.datasource.continue-on-error=true

+ 0
- 3
src/main/resources/application.properties View File

@@ -1,3 +0,0 @@
1
-spring.profiles.active=h2
2
-
3
-spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect

+ 0
- 11
src/main/resources/schema-h2.sql View File

@@ -1,11 +0,0 @@
1
-DROP TABLE PERSON;
2
-
3
-CREATE TABLE PERSON (
4
-ID NUMBER(10,0) NOT NULL AUTO_INCREMENT,
5
-FIRST_NAME VARCHAR2(255) DEFAULT NULL,
6
-LAST_NAME VARCHAR2(255) DEFAULT NULL,
7
-PRIMARY KEY (ID));
8
-
9
-DROP SEQUENCE hibernate_sequence;
10
-
11
-CREATE SEQUENCE hibernate_sequence;

+ 0
- 232
src/main/resources/static/Requests.html View File

@@ -1,232 +0,0 @@
1
-<!DOCTYPE html>
2
-<html lang="en">
3
-<head>
4
-    <meta charset="UTF-8">
5
-    <title>Title</title>
6
-    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
7
-    <style media="screen">
8
-    h2 {
9
-      font-size: 1.2em;
10
-    }
11
-
12
-    #mainContent {
13
-    display: inline-flex;
14
-    }
15
-
16
-    #displayContainer {
17
-      width: 50%;
18
-    }
19
-    </style>
20
-</head>
21
-<body>
22
-  <section id="mainContent">
23
-
24
-
25
-    <section id="requestForms">
26
-
27
-
28
-      <section>
29
-        <h2>GET person list</h2>
30
-        <button type="button" name="submitGetAll" onclick="getPeople()">Submit GET All</button>
31
-      </section>
32
-      <section>
33
-        <h2>GET person by id</h2>
34
-        <label for="getPersonId">Person ID:</label><input type="number" name="getPersonId" value="1" id="getPersonId"><br>
35
-        <button type="button" name="submitGet" onclick="getPerson()">Submit GET</button>
36
-      </section>
37
-      <section>
38
-        <h2>POST new Person:</h2>
39
-
40
-        <label for="firstName">First Name:</label><input type="text" name="firstName" value="foo" id="postPersonFirstName"><br>
41
-        <label for="lastName">Last Name:</label><input type="text" name="lastName" value="bar" id="postPersonLastName"><br>
42
-        <button type="button" name="submitPost" onclick="postPerson()">Submit POST</button>
43
-      </section>
44
-
45
-      <section>
46
-        <h2>PUT updated person</h2>
47
-        <label for="putFirstName">First Name:</label><input type="text" name="putFirstName" value="Han" id="putPersonFirstName"><br>
48
-        <label for="putLastName">Last Name:</label><input type="text" name="putLastName" value="Solo" id="putPersonLastName"><br>
49
-        <label for="putId">ID:</label><input type="number" name="putId" value="" id="putPersonId"><br>
50
-        <button type="button" name="submitPut" onclick="putPerson()">Submit PUT</button>
51
-      </section>
52
-
53
-      <section>
54
-        <h2>DELETE person by ID</h2>
55
-        <label for="delPersonId">Person ID:</label><input type="number" name="delPersonId" value="1" id="deletePersonId"><br>
56
-        <button type="button" name="submitDelete" onclick="deletePerson()">Submit DELETE</button>
57
-      </section>
58
-    </section>
59
-    <section id="displayContainer" >
60
-      <div class="display" id="displayBox" >
61
-        Nothing to Display
62
-      </div>
63
-
64
-    </section>
65
-  </section>
66
-<script>
67
-
68
-function updateDisplay(content, header){
69
-  var newContent = content;
70
-  if(header != null){
71
-    newContent = header + newContent;
72
-  }
73
-  document.getElementById("displayBox").innerHTML = newContent;
74
-}
75
-function postPerson(){
76
-  // get values from fields
77
-  var postFirstName = document.getElementById("postPersonFirstName").value;
78
-  var postLastName = document.getElementById("postPersonLastName").value;
79
-  var URI = "http://localhost:8080/people/";
80
-  var requestType = "POST";
81
-
82
-  var postData = JSON.stringify({
83
-  "firstName": postFirstName,
84
-  "lastName": postLastName
85
-});
86
-  console.log("Requesting post for person:");
87
-  console.log(postData);
88
-  // send POST request
89
-  var xhr = new XMLHttpRequest();
90
-xhr.withCredentials = true;
91
-
92
-xhr.addEventListener("readystatechange", function () {
93
-  if (this.readyState === 4) {
94
-    console.log(this)
95
-    console.log(this.responseText);
96
-    updateDisplay(this.responseText, requestType + URI + ":<br>");
97
-  }
98
-});
99
-
100
-xhr.open(requestType, URI);
101
-xhr.setRequestHeader("content-type", "application/json");
102
-xhr.setRequestHeader("cache-control", "no-cache");
103
-// xhr.setRequestHeader("postman-token", "b11af5d0-9526-b27a-e6fc-a89dc4d348fc");
104
-
105
-xhr.send(postData);
106
-  // update display with result
107
-}
108
-
109
-
110
-
111
-function putPerson(){
112
-  // get values from fields
113
-  // send POST request
114
-  // update display with result
115
-  // get values from fields
116
-  var putFirstName = document.getElementById("putPersonFirstName").value;
117
-  var putLastName = document.getElementById("putPersonLastName").value;
118
-  var putId = document.getElementById("putPersonId").value;
119
-  var URI = "http://localhost:8080/people/" + putId;
120
-  var requestType = "PUT";
121
-
122
-  var putData = JSON.stringify({
123
-  "firstName": putFirstName,
124
-  "lastName": putLastName,
125
-  "id": putId
126
-});
127
-  console.log("Requesting put for person:");
128
-  console.log(putData);
129
-  // send POST request
130
-  var xhr = new XMLHttpRequest();
131
-xhr.withCredentials = true;
132
-
133
-xhr.addEventListener("readystatechange", function () {
134
-  if (this.readyState === 4) {
135
-    console.log(this)
136
-    console.log(this.responseText);
137
-    // updateDisplay(this.responseText);
138
-    updateDisplay(this.responseText, requestType + URI + ":<br>");
139
-  }
140
-});
141
-
142
-xhr.open(requestType, URI);
143
-xhr.setRequestHeader("content-type", "application/json");
144
-xhr.setRequestHeader("cache-control", "no-cache");
145
-// xhr.setRequestHeader("postman-token", "b11af5d0-9526-b27a-e6fc-a89dc4d348fc");
146
-
147
-xhr.send(putData);
148
-}
149
-
150
-function getPerson(){
151
-
152
-  var getId = document.getElementById("getPersonId").value;
153
-  var URI = "http://localhost:8080/people/" + getId;
154
-  var requestType = "GET";
155
-  var xhr = new XMLHttpRequest();
156
-
157
-xhr.withCredentials = true;
158
-
159
-xhr.addEventListener("readystatechange", function () {
160
-  if (this.readyState === 4) {
161
-    console.log(this)
162
-    console.log(this.responseText);
163
-    updateDisplay(this.responseText, requestType + URI + ":<br>");
164
-  }
165
-});
166
-
167
-xhr.open(requestType, URI);
168
-xhr.setRequestHeader("content-type", "application/json");
169
-xhr.setRequestHeader("cache-control", "no-cache");
170
-// xhr.setRequestHeader("postman-token", "b11af5d0-9526-b27a-e6fc-a89dc4d348fc");
171
-
172
-xhr.send(null);
173
-  // get values from fields
174
-  // send POST request
175
-  // update display with result
176
-}
177
-
178
-function getPeople(){
179
-  // send GET /person request
180
-  // update display with result
181
-  var URI = "http://localhost:8080/people/";
182
-  var requestType = "GET";
183
-
184
-  var xhr = new XMLHttpRequest();
185
-xhr.withCredentials = true;
186
-
187
-xhr.addEventListener("readystatechange", function () {
188
-  if (this.readyState === 4) {
189
-    console.log(this)
190
-    console.log(this.responseText);
191
-    updateDisplay(this.responseText, requestType + URI + ":<br>");
192
-  }
193
-});
194
-
195
-xhr.open(requestType, URI);
196
-xhr.setRequestHeader("content-type", "application/json");
197
-xhr.setRequestHeader("cache-control", "no-cache");
198
-// xhr.setRequestHeader("postman-token", "b11af5d0-9526-b27a-e6fc-a89dc4d348fc");
199
-
200
-xhr.send(null);
201
-}
202
-
203
-function deletePerson(){
204
-
205
-    var deleteId = document.getElementById("deletePersonId").value;
206
-    var URI = "http://localhost:8080/people/" + deleteId;
207
-    var requestType = "DELETE";
208
-    var xhr = new XMLHttpRequest();
209
-
210
-  xhr.withCredentials = true;
211
-
212
-  xhr.addEventListener("readystatechange", function () {
213
-    if (this.readyState === 4) {
214
-      console.log(this)
215
-      console.log(this.responseText);
216
-      updateDisplay(this.responseText, requestType + URI + ":<br>");
217
-    }
218
-  });
219
-
220
-  xhr.open(requestType, URI);
221
-  xhr.setRequestHeader("content-type", "application/json");
222
-  xhr.setRequestHeader("cache-control", "no-cache");
223
-  // xhr.setRequestHeader("postman-token", "b11af5d0-9526-b27a-e6fc-a89dc4d348fc");
224
-
225
-  xhr.send(null);
226
-  // get values from fields
227
-  // send DELETE request
228
-  // update display with result
229
-}
230
-</script>
231
-</body>
232
-</html>

src/test/java/io/zipcoder/crudapp/CRUDApplicationTests.java → src/test/java/com/personcontroller/demo/DemoApplicationTests.java View File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.crudapp;
1
+package com.personcontroller.demo;
2 2
 
3 3
 import org.junit.Test;
4 4
 import org.junit.runner.RunWith;
@@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
7 7
 
8 8
 @RunWith(SpringRunner.class)
9 9
 @SpringBootTest
10
-public class CRUDApplicationTests {
10
+public class DemoApplicationTests {
11 11
 
12 12
 	@Test
13 13
 	public void contextLoads() {