Bladeren bron

added more repository classes and tests

William Simkins 6 jaren geleden
bovenliggende
commit
a4ab38d345
27 gewijzigde bestanden met toevoegingen van 304 en 161 verwijderingen
  1. 0
    13
      src/main/java/com/tyler/motivateme/Forum.java
  2. 0
    13
      src/main/java/com/tyler/motivateme/Inbox.java
  3. 0
    19
      src/main/java/com/tyler/motivateme/MainTopicsPage.java
  4. 0
    13
      src/main/java/com/tyler/motivateme/controller/CommentController.java
  5. 28
    0
      src/main/java/com/tyler/motivateme/controller/ForumController.java
  6. 34
    0
      src/main/java/com/tyler/motivateme/controller/InboxController.java
  7. 12
    3
      src/main/java/com/tyler/motivateme/controller/MainTopicsPageController.java
  8. 0
    13
      src/main/java/com/tyler/motivateme/controller/MessageController.java
  9. 18
    2
      src/main/java/com/tyler/motivateme/controller/TopicCreatorController.java
  10. 11
    5
      src/main/java/com/tyler/motivateme/controller/TopicInfoPageController.java
  11. 15
    0
      src/main/java/com/tyler/motivateme/model/Comment.java
  12. 13
    0
      src/main/java/com/tyler/motivateme/model/Message.java
  13. 0
    47
      src/main/java/com/tyler/motivateme/model/TopicCreatorService.java
  14. 9
    0
      src/main/java/com/tyler/motivateme/repository/CommentRepository.java
  15. 9
    0
      src/main/java/com/tyler/motivateme/repository/MessageRepository.java
  16. 19
    0
      src/main/java/com/tyler/motivateme/service/ForumService.java
  17. 21
    0
      src/main/java/com/tyler/motivateme/service/InboxService.java
  18. 23
    0
      src/main/java/com/tyler/motivateme/service/MainTopicsPageService.java
  19. 29
    0
      src/main/java/com/tyler/motivateme/service/TopicCreatorService.java
  20. 2
    2
      src/main/java/com/tyler/motivateme/service/TopicInfoPageService.java
  21. 2
    1
      src/main/resources/application.properties
  22. 27
    0
      src/test/java/model/topicTest.java
  23. 2
    3
      src/test/java/service/ForumServiceTest.java
  24. 2
    3
      src/test/java/service/InboxServiceTest.java
  25. 2
    3
      src/test/java/service/MainTopicsPageServiceTest.java
  26. 24
    18
      src/test/java/service/TopicCreatorServiceTest.java
  27. 2
    3
      src/test/java/service/TopicInfoPageServiceTest.java

+ 0
- 13
src/main/java/com/tyler/motivateme/Forum.java Bestand weergeven

@@ -1,13 +0,0 @@
1
-package com.tyler.motivateme;
2
-
3
-public class Forum {
4
-    private int forumId;
5
-
6
-    public Forum(int forumId) {
7
-        this.forumId = forumId;
8
-    }
9
-
10
-    public String postComment(int id){
11
-        return null;
12
-    }
13
-}

+ 0
- 13
src/main/java/com/tyler/motivateme/Inbox.java Bestand weergeven

@@ -1,13 +0,0 @@
1
-package com.tyler.motivateme;
2
-
3
-public class Inbox {
4
-    private int id;
5
-
6
-    public Inbox(int id){
7
-        this.id = id;
8
-    }
9
-
10
-    public String sendMessage(int id){
11
-        return null;
12
-    }
13
-}

+ 0
- 19
src/main/java/com/tyler/motivateme/MainTopicsPage.java Bestand weergeven

@@ -1,19 +0,0 @@
1
-package com.tyler.motivateme;
2
-
3
-import com.tyler.motivateme.model.Topic;
4
-import org.springframework.context.annotation.Bean;
5
-import org.springframework.stereotype.Service;
6
-
7
-import java.util.ArrayList;
8
-import java.util.List;
9
-
10
-@Service
11
-public class MainTopicsPage {
12
-    List<Topic> topicsList;
13
-
14
-    public MainTopicsPage(){
15
-        this.topicsList = new ArrayList<>();
16
-    }
17
-
18
-
19
-}

+ 0
- 13
src/main/java/com/tyler/motivateme/controller/CommentController.java Bestand weergeven

@@ -1,13 +0,0 @@
1
-package com.tyler.motivateme.controller;
2
-
3
-import org.springframework.web.bind.annotation.RequestMapping;
4
-import org.springframework.web.bind.annotation.RestController;
5
-
6
-@RestController
7
-@RequestMapping("/comments")
8
-public class CommentController {
9
-
10
-    public String postComment(int id){
11
-        return null;
12
-    }
13
-}

+ 28
- 0
src/main/java/com/tyler/motivateme/controller/ForumController.java Bestand weergeven

@@ -0,0 +1,28 @@
1
+package com.tyler.motivateme.controller;
2
+
3
+import com.tyler.motivateme.model.Topic;
4
+import com.tyler.motivateme.service.ForumService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RequestMethod;
8
+import org.springframework.web.bind.annotation.RestController;
9
+
10
+@RestController
11
+public class ForumController {
12
+    @Autowired
13
+    ForumService forumService;
14
+
15
+    @RequestMapping(method = RequestMethod.POST, value = "/forum")
16
+    public void PostComment(int forumID){
17
+        forumService.postComment(forumID); }
18
+
19
+    @RequestMapping(method = RequestMethod.PUT, value = "/forum/{id}")
20
+    public void updateComment(int commentID){
21
+        forumService.updateComment(commentID); }
22
+
23
+    @RequestMapping(method = RequestMethod.DELETE, value = "/forum/{id}")
24
+    public void deleteComment(int commentID){
25
+        forumService.deleteComment(commentID); }
26
+
27
+
28
+}

+ 34
- 0
src/main/java/com/tyler/motivateme/controller/InboxController.java Bestand weergeven

@@ -0,0 +1,34 @@
1
+package com.tyler.motivateme.controller;
2
+
3
+import com.tyler.motivateme.model.Topic;
4
+import com.tyler.motivateme.service.InboxService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RequestMethod;
8
+import org.springframework.web.bind.annotation.RestController;
9
+
10
+@RestController
11
+@RequestMapping("/Inbox")
12
+public class InboxController {
13
+    @Autowired
14
+    InboxService inboxService;
15
+
16
+    @RequestMapping(method = RequestMethod.POST, value = "/inbox")
17
+    public void sendMessage(int userID){
18
+        inboxService.sendMessage(userID); }
19
+
20
+    @RequestMapping(method = RequestMethod.GET, value = "/inbox/{id}")
21
+    public void viewMessage(int messageID){
22
+        inboxService.viewMessage(messageID); }
23
+
24
+
25
+    @RequestMapping(method = RequestMethod.PUT, value = "/inbox/{id}")
26
+    public void updateMessage(int messageID){
27
+        inboxService.updateMessage(messageID); }
28
+
29
+    @RequestMapping(method = RequestMethod.DELETE, value = "/inbox/{id}")
30
+    public void deleteMessage(int messageID){
31
+        inboxService.deleteMessage(messageID); }
32
+
33
+
34
+}

+ 12
- 3
src/main/java/com/tyler/motivateme/controller/MainTopicsPageController.java Bestand weergeven

@@ -1,13 +1,22 @@
1 1
 package com.tyler.motivateme.controller;
2 2
 
3
-import com.tyler.motivateme.MainTopicsPage;
3
+import com.tyler.motivateme.model.Topic;
4
+import com.tyler.motivateme.service.MainTopicsPageService;
4 5
 import org.springframework.beans.factory.annotation.Autowired;
5 6
 import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RequestMethod;
6 8
 import org.springframework.web.bind.annotation.RestController;
7 9
 
10
+import java.util.List;
11
+
8 12
 @RestController
9
-@RequestMapping("/MainTopics")
10 13
 public class MainTopicsPageController {
11 14
     @Autowired
12
-    MainTopicsPage mainTopicsPage;
15
+    MainTopicsPageService mainTopicsPageService;
16
+
17
+    @RequestMapping(method = RequestMethod.GET, value = "/topics")
18
+    public List<Topic> allTopics() {
19
+
20
+        return mainTopicsPageService.allTopics();
21
+    }
13 22
 }

+ 0
- 13
src/main/java/com/tyler/motivateme/controller/MessageController.java Bestand weergeven

@@ -1,13 +0,0 @@
1
-package com.tyler.motivateme.controller;
2
-
3
-import org.springframework.web.bind.annotation.RequestMapping;
4
-import org.springframework.web.bind.annotation.RestController;
5
-
6
-@RestController
7
-@RequestMapping("/messages")
8
-public class MessageController {
9
-
10
-    public String sendMessage(int id){
11
-        return null;
12
-    }
13
-}

+ 18
- 2
src/main/java/com/tyler/motivateme/controller/TopicCreatorController.java Bestand weergeven

@@ -1,23 +1,39 @@
1 1
 package com.tyler.motivateme.controller;
2 2
 
3
-import com.tyler.motivateme.model.TopicCreatorService;
3
+import com.tyler.motivateme.service.TopicCreatorService;
4 4
 import com.tyler.motivateme.model.Topic;
5 5
 import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.PostMapping;
6 7
 import org.springframework.web.bind.annotation.RequestMapping;
8
+import org.springframework.web.bind.annotation.RequestMethod;
7 9
 import org.springframework.web.bind.annotation.RestController;
8 10
 
9 11
 import java.util.List;
10 12
 
11 13
 @RestController
12
-@RequestMapping("/topics")
13 14
 public class TopicCreatorController {
14 15
 
15 16
     @Autowired
16 17
     private TopicCreatorService topicCreatorService;
17 18
 
19
+    @RequestMapping(method = RequestMethod.GET, value = "/CreateTopic")
18 20
     public List<Topic> allTopics() {
19 21
 
20 22
         return topicCreatorService.allTopics();
21 23
     }
22 24
 
25
+    @RequestMapping(method = RequestMethod.POST, value = "/CreateTopic")
26
+    public void add(Topic topic){
27
+        topicCreatorService.add(topic); }
28
+
29
+    @RequestMapping(method = RequestMethod.PUT, value = "/CreateTopic/{id}")
30
+    public void update(Topic topic){
31
+        topicCreatorService.update(topic); }
32
+
33
+    @RequestMapping(method = RequestMethod.DELETE, value = "/CreateTopic/{id}")
34
+    public void delete(Topic topic){
35
+        topicCreatorService.delete(topic); }
36
+
37
+
38
+
23 39
 }

+ 11
- 5
src/main/java/com/tyler/motivateme/controller/TopicInfoPageController.java Bestand weergeven

@@ -1,18 +1,24 @@
1 1
 package com.tyler.motivateme.controller;
2 2
 
3
-import com.tyler.motivateme.MainTopicsPage;
3
+import com.tyler.motivateme.service.TopicInfoPageService;
4 4
 import org.springframework.beans.factory.annotation.Autowired;
5 5
 import org.springframework.web.bind.annotation.RequestMapping;
6 6
 import org.springframework.web.bind.annotation.RestController;
7 7
 
8 8
 @RestController
9
-@RequestMapping("/TopicInfo")
10 9
 public class TopicInfoPageController {
11 10
 
12 11
     @Autowired
13
-    private MainTopicsPage mainTopicsPage;
12
+    private TopicInfoPageService topicInfoPageService;
14 13
 
15
-    public String getDescription() {return null;}
16
-    public String getAdviceAndStrategies() {return null;}
14
+    public void getTopicName() {}
15
+
16
+    public void getDescription() {
17
+
18
+    }
19
+
20
+    public void getAdviceAndStrategies() {
21
+
22
+    }
17 23
 
18 24
 }

+ 15
- 0
src/main/java/com/tyler/motivateme/model/Comment.java Bestand weergeven

@@ -0,0 +1,15 @@
1
+package com.tyler.motivateme.model;
2
+
3
+import org.springframework.stereotype.Repository;
4
+
5
+import javax.persistence.Entity;
6
+import javax.persistence.GeneratedValue;
7
+import javax.persistence.GenerationType;
8
+import javax.persistence.Id;
9
+
10
+@Entity
11
+public class Comment {
12
+    @Id
13
+    @GeneratedValue(strategy = GenerationType.AUTO)
14
+    private int commentID;
15
+}

+ 13
- 0
src/main/java/com/tyler/motivateme/model/Message.java Bestand weergeven

@@ -0,0 +1,13 @@
1
+package com.tyler.motivateme.model;
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 Message {
10
+    @Id
11
+    @GeneratedValue(strategy = GenerationType.AUTO)
12
+    private int messageID;
13
+}

+ 0
- 47
src/main/java/com/tyler/motivateme/model/TopicCreatorService.java Bestand weergeven

@@ -1,47 +0,0 @@
1
-package com.tyler.motivateme.model;
2
-
3
-import org.springframework.stereotype.Service;
4
-
5
-import java.util.ArrayList;
6
-import java.util.Arrays;
7
-import java.util.List;
8
-
9
-@Service
10
-public class TopicCreatorService {
11
-
12
-    private List<Topic> topics;
13
-    private String description;
14
-    private String adviceAndStrategies;
15
-
16
-    public TopicCreatorService(){
17
-        this.topics = topics = new ArrayList<Topic>(Arrays.asList(new Topic(1, "Quit drinking"), new Topic(2, "Quit Smoking"), new Topic(3, "Eat healthier")));
18
-        this.description = description;
19
-        this.adviceAndStrategies = adviceAndStrategies;
20
-    }
21
-
22
-    public List<Topic> allTopics() {
23
-
24
-        return topics;
25
-    }
26
-
27
-    public void setDescription(String description) {
28
-        this.description = description;
29
-    }
30
-
31
-    public void setAdviceAndStrategies(String adviceAndStrategies) {
32
-        this.adviceAndStrategies = adviceAndStrategies;
33
-    }
34
-
35
-    public String getDescription() {
36
-
37
-        return description;
38
-    }
39
-
40
-    public String getAdviceAndStrategies() {
41
-        return adviceAndStrategies;
42
-    }
43
-
44
-    public void add(Topic topic) {
45
-        topics.add(topic);
46
-    }
47
-}

+ 9
- 0
src/main/java/com/tyler/motivateme/repository/CommentRepository.java Bestand weergeven

@@ -0,0 +1,9 @@
1
+package com.tyler.motivateme.repository;
2
+
3
+import com.tyler.motivateme.model.Comment;
4
+import org.springframework.data.repository.CrudRepository;
5
+import org.springframework.stereotype.Repository;
6
+
7
+@Repository
8
+public interface CommentRepository extends CrudRepository<Comment, Integer> {
9
+}

+ 9
- 0
src/main/java/com/tyler/motivateme/repository/MessageRepository.java Bestand weergeven

@@ -0,0 +1,9 @@
1
+package com.tyler.motivateme.repository;
2
+
3
+import com.tyler.motivateme.model.Message;
4
+import org.springframework.data.repository.CrudRepository;
5
+import org.springframework.stereotype.Repository;
6
+
7
+@Repository
8
+public interface MessageRepository extends CrudRepository<Message, Integer> {
9
+}

+ 19
- 0
src/main/java/com/tyler/motivateme/service/ForumService.java Bestand weergeven

@@ -0,0 +1,19 @@
1
+package com.tyler.motivateme.service;
2
+
3
+import org.springframework.stereotype.Service;
4
+
5
+@Service
6
+public class ForumService {
7
+    private Integer forumID;
8
+//
9
+//    public ForumService(Integer forumID) {
10
+//        this.forumID = forumID;
11
+//    }
12
+
13
+    public void postComment(int forumID){
14
+    }
15
+
16
+    public void updateComment(int commentID) {}
17
+
18
+    public void deleteComment(int commentID) {}
19
+}

+ 21
- 0
src/main/java/com/tyler/motivateme/service/InboxService.java Bestand weergeven

@@ -0,0 +1,21 @@
1
+package com.tyler.motivateme.service;
2
+
3
+import org.springframework.stereotype.Service;
4
+
5
+@Service
6
+public class InboxService {
7
+    private int userID;
8
+
9
+//    public InboxService(int userID){
10
+//        this.userID = userID;
11
+//    }
12
+
13
+    public void sendMessage(int userID){
14
+    }
15
+
16
+    public void viewMessage(int messageID) {}
17
+
18
+    public void updateMessage(int messageID) {}
19
+
20
+    public void deleteMessage(int messageID) {}
21
+}

+ 23
- 0
src/main/java/com/tyler/motivateme/service/MainTopicsPageService.java Bestand weergeven

@@ -0,0 +1,23 @@
1
+package com.tyler.motivateme.service;
2
+
3
+import com.tyler.motivateme.model.Topic;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.stereotype.Service;
6
+
7
+import java.util.ArrayList;
8
+import java.util.List;
9
+
10
+@Service
11
+public class MainTopicsPageService {
12
+    List<Topic> topics;
13
+
14
+    public MainTopicsPageService(){
15
+        this.topics = new ArrayList<>();
16
+    }
17
+
18
+    public List<Topic> allTopics() {
19
+
20
+        return topics;
21
+    }
22
+
23
+}

+ 29
- 0
src/main/java/com/tyler/motivateme/service/TopicCreatorService.java Bestand weergeven

@@ -0,0 +1,29 @@
1
+package com.tyler.motivateme.service;
2
+
3
+import com.tyler.motivateme.model.Topic;
4
+import org.springframework.stereotype.Service;
5
+
6
+import java.util.ArrayList;
7
+import java.util.Arrays;
8
+import java.util.List;
9
+
10
+@Service
11
+public class TopicCreatorService {
12
+
13
+    private List<Topic> topics = new ArrayList<Topic>(Arrays.asList(new Topic(1, "Quit drinking"), new Topic(2, "Quit Smoking"), new Topic(3, "Eat healthier")));
14
+    private String description;
15
+    private String adviceAndStrategies;
16
+
17
+    public List<Topic> allTopics() {
18
+
19
+        return topics;
20
+    }
21
+
22
+    public void add(Topic topic) {
23
+        topics.add(topic);
24
+    }
25
+
26
+    public void update(Topic topic) {}
27
+
28
+    public void delete(Topic topic) { topics.remove(topic); }
29
+}

src/main/java/com/tyler/motivateme/TopicInfoPage.java → src/main/java/com/tyler/motivateme/service/TopicInfoPageService.java Bestand weergeven

@@ -1,9 +1,9 @@
1
-package com.tyler.motivateme;
1
+package com.tyler.motivateme.service;
2 2
 
3 3
 import org.springframework.stereotype.Service;
4 4
 
5 5
 @Service
6
-public class TopicInfoPage{
6
+public class TopicInfoPageService {
7 7
 
8 8
     public String getTopicName() {return null;}
9 9
 

+ 2
- 1
src/main/resources/application.properties Bestand weergeven

@@ -1,3 +1,4 @@
1 1
 spring.jpa.hibernate.ddl-auto=create-drop
2
-spring.datasource.url=jdbc:mysql://localhost:3306/demo1?useSSL=false
2
+spring.datasource.url=jdbc:mysql://localhost:3306/motivateme?useSSL=false
3 3
 spring.datasource.username=root
4
+spring.datasource.password=password

+ 27
- 0
src/test/java/model/topicTest.java Bestand weergeven

@@ -0,0 +1,27 @@
1
+package model;
2
+
3
+import com.tyler.motivateme.model.Topic;
4
+import org.junit.Test;
5
+
6
+import static org.junit.Assert.assertEquals;
7
+
8
+public class topicTest {
9
+
10
+    Topic topic = new Topic();
11
+
12
+    @Test
13
+    public void testGetDescription() {
14
+        String expected = "This is a description of the topic";
15
+        topic.setDescription(expected);
16
+        String actual = topic.getDescription();
17
+        assertEquals(expected, actual);
18
+    }
19
+
20
+    @Test
21
+    public void testGetAdviceAndStrategies() {
22
+        String expected = "This is the advice and strategies section of the topic";
23
+        topic.setAdviceAndStrategies(expected);
24
+        String actual = topic.getAdviceAndStrategies();
25
+        assertEquals(expected, actual);
26
+    }
27
+}

src/test/java/View/ForumTest.java → src/test/java/service/ForumServiceTest.java Bestand weergeven

@@ -1,14 +1,13 @@
1
-package View;
1
+package service;
2 2
 
3 3
 import org.junit.Test;
4 4
 import org.junit.runner.RunWith;
5
-import org.springframework.boot.test.context.SpringBootTest;
6 5
 import org.springframework.test.context.ContextConfiguration;
7 6
 import org.springframework.test.context.junit4.SpringRunner;
8 7
 
9 8
 @RunWith(SpringRunner.class)
10 9
 @ContextConfiguration
11
-public class ForumTest {
10
+public class ForumServiceTest {
12 11
 
13 12
     @Test
14 13
     public void testPostComment() {

src/test/java/View/InboxTest.java → src/test/java/service/InboxServiceTest.java Bestand weergeven

@@ -1,14 +1,13 @@
1
-package View;
1
+package service;
2 2
 
3 3
 import org.junit.Test;
4 4
 import org.junit.runner.RunWith;
5
-import org.springframework.boot.test.context.SpringBootTest;
6 5
 import org.springframework.test.context.ContextConfiguration;
7 6
 import org.springframework.test.context.junit4.SpringRunner;
8 7
 
9 8
 @RunWith(SpringRunner.class)
10 9
 @ContextConfiguration
11
-public class InboxTest {
10
+public class InboxServiceTest {
12 11
 
13 12
     @Test
14 13
     public void testSendMessage() {

src/test/java/View/MainTopicsPageTest.java → src/test/java/service/MainTopicsPageServiceTest.java Bestand weergeven

@@ -1,14 +1,13 @@
1
-package View;
1
+package service;
2 2
 
3 3
 import org.junit.Test;
4 4
 import org.junit.runner.RunWith;
5
-import org.springframework.boot.test.context.SpringBootTest;
6 5
 import org.springframework.test.context.ContextConfiguration;
7 6
 import org.springframework.test.context.junit4.SpringRunner;
8 7
 
9 8
 @RunWith(SpringRunner.class)
10 9
 @ContextConfiguration
11
-public class MainTopicsPageTest {
10
+public class MainTopicsPageServiceTest {
12 11
 
13 12
     @Test
14 13
     public void testGetDescription(){

src/test/java/model/TopicCreatorServiceTest.java → src/test/java/service/TopicCreatorServiceTest.java Bestand weergeven

@@ -1,7 +1,7 @@
1
-package model;
1
+package service;
2 2
 
3 3
 import com.tyler.motivateme.model.Topic;
4
-import com.tyler.motivateme.model.TopicCreatorService;
4
+import com.tyler.motivateme.service.TopicCreatorService;
5 5
 import org.junit.Test;
6 6
 import org.junit.runner.RunWith;
7 7
 import org.springframework.test.context.ContextConfiguration;
@@ -12,6 +12,7 @@ import java.util.Arrays;
12 12
 import java.util.List;
13 13
 
14 14
 import static org.junit.Assert.assertEquals;
15
+import static org.junit.Assert.assertFalse;
15 16
 import static org.junit.Assert.assertTrue;
16 17
 
17 18
 @RunWith(SpringRunner.class)
@@ -20,21 +21,6 @@ public class TopicCreatorServiceTest {
20 21
 
21 22
     TopicCreatorService tcs = new TopicCreatorService();
22 23
 
23
-    @Test
24
-    public void testGetDescription() {
25
-        String expected = "This is a description of the topic";
26
-        tcs.setDescription(expected);
27
-        String actual = tcs.getDescription();
28
-        assertEquals(expected, actual);
29
-    }
30
-
31
-    @Test
32
-    public void testGetAdviceAndStrategies() {
33
-        String expected = "This is the advice and strategies section of the topic";
34
-        tcs.setAdviceAndStrategies(expected);
35
-        String actual = tcs.getAdviceAndStrategies();
36
-        assertEquals(expected, actual);
37
-    }
38 24
 
39 25
     @Test
40 26
     public void testAllTopics_AreInList(){
@@ -53,7 +39,7 @@ public class TopicCreatorServiceTest {
53 39
     }
54 40
 
55 41
     @Test
56
-    public void testAddTopics_toAllTopics(){
42
+    public void testAddTopic_ToAllTopics(){
57 43
         Topic topic = new Topic(4, "working out");
58 44
         tcs.add(topic);
59 45
 
@@ -61,4 +47,24 @@ public class TopicCreatorServiceTest {
61 47
 
62 48
         assertTrue(topics.contains(topic));
63 49
     }
50
+
51
+    @Test
52
+    public void testUpdateTopic_InAllTopics(){
53
+        Topic topic = new Topic(4, "working out");
54
+        tcs.update(topic);
55
+
56
+        List<Topic> topics = tcs.allTopics();
57
+
58
+        assertFalse(topics.contains(topic));
59
+    }
60
+
61
+    @Test
62
+    public void testDeleteTopic_FromAllTopics(){
63
+        Topic topic = new Topic(2, "Quit Smoking");
64
+        tcs.delete(topic);
65
+
66
+        List<Topic> topics = tcs.allTopics();
67
+
68
+        assertFalse(topics.contains(topic));
69
+    }
64 70
 }

src/test/java/View/TopicInfoPageTest.java → src/test/java/service/TopicInfoPageServiceTest.java Bestand weergeven

@@ -1,14 +1,13 @@
1
-package View;
1
+package service;
2 2
 
3 3
 import org.junit.Test;
4 4
 import org.junit.runner.RunWith;
5
-import org.springframework.boot.test.context.SpringBootTest;
6 5
 import org.springframework.test.context.ContextConfiguration;
7 6
 import org.springframework.test.context.junit4.SpringRunner;
8 7
 
9 8
 @RunWith(SpringRunner.class)
10 9
 @ContextConfiguration
11
-public class TopicInfoPageTest {
10
+public class TopicInfoPageServiceTest {
12 11
 
13 12
     @Test
14 13
     public void testGetDescription() {