8000 thymeleaf sandbox testing · blackbeltcoder/Todoo@6742491 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6742491

Browse files
author
genio
committed
thymeleaf sandbox testing
1 parent 2f2ad76 commit 6742491

File tree

8 files changed

+95
-1
lines changed

8 files changed

+95
-1
lines changed

gradlew

100644100755
File mode changed.

src/main/java/com/sar/sandpit/Item.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Item {
1414
private final String details;
1515
@Id
1616
@GeneratedValue(strategy = GenerationType.AUTO)
17-
private long id;
17+
private final long id;
1818

1919
public Item(){
2020
this(0,"");
@@ -36,4 +36,10 @@ public <T> long getId() {
3636
public <T> String getDetails() {
3737
return details;
3838
}
39+
40+
41+
public void testMethod(String test){
42+
System.out.println(test.toUpperCase()+"\n");
43+
}
44+
3945
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.sar.sandpit;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.ModelMap;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RequestMethod;
7+
import org.springframework.web.bind.annotation.ValueConstants;
8+
9+
/**
10+
* Created by genio on 27/11/16.
11+
*/
12+
13+
@Controller
14+
@RequestMapping("todo")
15+
public class ItemController {
16+
17+
@RequestMapping( method = RequestMethod.GET)
18+
public String home(){
19+
return "todo/index";
20+
}
21+
22+
23+
@RequestMapping(value = "items" , method = RequestMethod.GET)
24+
public String items(ModelMap modalMap){
25+
26+
27+
modalMap.put("test", "helloworld");
28+
29+
return "todo/items";
30+
}
31+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html
3+
xmlns:th ="http://thymeleaf.org"
4+
lang="en">
5+
6+
<head>
7+
<meta charset="UTF-8"/>
8+
<title>Todoo 2</title>
9+
</head>
10+
<body>
11+
12+
</body>
13+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html xmlns:th="http://www.thymeleaf.org"
3+
lang="en">
4+
<head>
5+
<meta charset="UTF-8"/>
6+
<title>Items</title>
7+
</head>
8+
<body>
9+
10+
<p th:text="'test 1 = '+ ${test}"></p>
11+
12+
<p th:text="'test 2 = '+ ${test}">not empty</p>
13+
14+
th:text="'test 3 = '+ ${test}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.sar.sandpit;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
6+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
7+
import org.springframework.boot.test.context.SpringBootTest;
8+
import org.springframework.test.context.junit4.SpringRunner;
9+
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
10+
11+
/**
12+
* Created by genio on 20/11/16.
13+
*/
14+
@RunWith(SpringRunner.class)
15+
//@SpringBootTest
16+
//@AutoConfigureMockMvc full mvc mock
17+
@WebMvcTest // Just the web context
18+
public class ItemControllerTest {
19+
20+
@Test
21+
public void displayItem_StoreHasOneItem_Success() throws Exception {
22+
23+
throw new NotImplementedException();
24+
25+
26+
}
27+
}

src/test/java/com/sar/sandpit/ItemRepositoryTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void saveItemToRepository_emptyRepo_success() throws Exception {
4646

4747
// ItemStorable itemRepo2 = new FakeItemRepository();
4848

49+
4950
//// TODO: 24/10/16 refactor to method build basic repo list
5051
assertThat("should increase by one ",itemRepo2.count(), is(equalTo(0L)));
5152
itemRepo2.save(new Item(1));

src/test/java/com/sar/sandpit/ItemServiceTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.runner.RunWith;
66
import org.mockito.*;
77

8+
import org.springframework.boot.test.context.SpringBootTest;
89
import org.springframework.boot.test.mock.mockito.MockBean;
910
import org.springframework.test.context.junit4.SpringRunner;
1011

@@ -19,6 +20,7 @@
1920
*/
2021

2122
@RunWith(SpringRunner.class)
23+
@SpringBootTest
2224
//@RunWith(MockitoJUnitRunner.class)
2325
public class ItemServiceTest {
2426

0 commit comments

Comments
 (0)
0