Sfoglia il codice sorgente

PersonController - Complete

Nick Satinover 6 anni fa
parent
commit
c1771f5ce7

+ 39
- 1
src/test/java/io/zipcoder/crudapp/CRUDApplicationTests.java Vedi File

@@ -1,16 +1,54 @@
1 1
 package io.zipcoder.crudapp;
2 2
 
3
+import org.junit.Assert;
4
+import org.junit.Before;
3 5
 import org.junit.Test;
4 6
 import org.junit.runner.RunWith;
7
+import org.springframework.beans.factory.annotation.Autowired;
5 8
 import org.springframework.boot.test.context.SpringBootTest;
9
+import org.springframework.http.HttpEntity;
10
+import org.springframework.http.HttpStatus;
11
+import org.springframework.http.ResponseEntity;
6 12
 import org.springframework.test.context.junit4.SpringRunner;
7 13
 
8 14
 @RunWith(SpringRunner.class)
9 15
 @SpringBootTest
10 16
 public class CRUDApplicationTests {
11 17
 
18
+	@Autowired
19
+	PersonController personController;
20
+
21
+	@Autowired
22
+	PersonRepository personRepository;
23
+
24
+	@Before
25
+	public void setUp() {
26
+        Person person = new Person("Nick", "Satinover");
27
+        personController.createPerson(person);
28
+	}
29
+
12 30
 	@Test
13
-	public void contextLoads() {
31
+	public void PersonControllerCreateTest(){
32
+		// given
33
+            //SetUp
34
+		// when
35
+		String expected = "Satinover";
36
+		String actual = personRepository.findOne(1).getLastName();
37
+
38
+		// then
39
+		Assert.assertEquals(expected, actual);
14 40
 	}
15 41
 
42
+    @Test
43
+    public void PersonControllerGetTest(){
44
+        // given
45
+        //SetUp
46
+        // when
47
+        //String expected = "Satinover";
48
+//        Person actual = personController.getPerson(1);
49
+
50
+        // then
51
+        //Assert.assertEquals(expected, actual);
52
+    }
53
+
16 54
 }