• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

edoardof01 / sessionBuilder / 142

23 Jun 2025 03:53PM UTC coverage: 0.0%. Remained the same
142

push

github

edoardof01
modifica al codice per popolare i models della UI coi records del db

0 of 282 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 45 new or added lines in 7 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 930 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sessionBuilder/sessionBuilder-core/src/main/java/com/sessionBuilder/core/TopicService.java
1
package com.sessionBuilder.core;
2

3

4
import java.util.List;
5

6
import com.google.inject.Inject;
7

8
public class TopicService implements TopicServiceInterface {
×
9
        
10
        @Inject
11
        private TopicRepositoryInterface topicRepository;
12
        
13
        @Inject
14
        private TransactionManager tm;
15
        
16
        private static final String TOPIC_EXCEPTION_MESSAGE = "il topic passato è null";
17

18
        @Override
19
        public Topic createTopic(String name, String description, int difficulty, List<StudySession> sessionList) {
20
                return tm.doInTopicTransaction(repository -> {
×
21
                        Topic topic = new Topic(name, description, difficulty, sessionList);
×
22
                        if(repository.findByNameDescriptionAndDifficulty(name, description, difficulty) != null) 
×
23
                                throw new IllegalArgumentException("Esiste già un topic con questi valori");
×
24
                        topicRepository.save(topic);
×
25
                        return topic;
×
26
                });
27
        }
28

29
        @Override
30
        public Topic getTopicById(long topicId) {
31
                return tm.doInTopicTransaction(repository -> {
×
32
                        Topic topic = repository.findById(topicId);
×
33
                        if(topic == null) throw new IllegalArgumentException("il topic cercato non esiste");
×
34
                        return topic;
×
35
                });
36
        }
37
        
38
        @Override
39
        public List<Topic> getAllTopics() {
NEW
40
                return tm.doInTopicTransaction(repository -> {
×
41
                        try {
NEW
42
                                return repository.findAll();
×
NEW
43
                        } catch (Exception e) {
×
NEW
44
                                throw new IllegalArgumentException("Errore durante il caricamento dei topic");
×
45
                        }
46
                 });
47
        }
48

49

50
        @Override
51
        public void addSessionToTopic(long topicId, long sessionId) {
52
                tm.doInMultiRepositoryTransaction(context -> {
×
53
                        Topic topic = context.getTopicRepository().findById(topicId);
×
54
                        StudySession session = context.getSessionRepository().findById(sessionId);
×
55
                        if(topic == null) throw new IllegalArgumentException(TOPIC_EXCEPTION_MESSAGE);
×
56
                        if(session == null) throw new IllegalArgumentException("la sessione passata è null");
×
57
                        topic.addSession(session);
×
58
                        context.getTopicRepository().update(topic);
×
59
                        return null;
×
60
                });
61
        }
×
62
        
63
        @Override
64
        public void removeSessionFromTopic(long topicId, long sessionId) {
65
                tm.doInMultiRepositoryTransaction(context -> {
×
66
                        Topic topic = context.getTopicRepository().findById(topicId);
×
67
                        StudySession session = context.getSessionRepository().findById(sessionId);
×
68
                        if(topic == null) throw new IllegalArgumentException(TOPIC_EXCEPTION_MESSAGE);
×
69
                        if(session == null) throw new IllegalArgumentException("la sessione passata è null");
×
70
                        topic.removeSession(session);
×
71
                        context.getTopicRepository().update(topic);
×
72
                        return null;
×
73
                });
74
        }
×
75
        
76
        @Override
77
        public void deleteTopic(long topicId) {
78
                tm.doInTopicTransaction(repository -> {
×
79
                        Topic topic = repository.findById(topicId);
×
80
                        if(topic == null) throw new IllegalArgumentException(TOPIC_EXCEPTION_MESSAGE);
×
81
                        repository.delete(topicId);
×
82
                        return null;
×
83
                });
84
        }
×
85

86

87
        @Override
88
        public int calculateTotalTime(long topicId) {
89
                return tm.doInTopicTransaction(repository -> {
×
90
                        Topic topic = repository.findById(topicId);
×
91
                        if(topic == null) throw new IllegalArgumentException(TOPIC_EXCEPTION_MESSAGE);
×
92
                        return topic.totalTime();
×
93
                });
94
        }
95

96
        @Override
97
        public int calculatePercentageOfCompletion(long topicId) {
98
                return tm.doInTopicTransaction(repository -> {
×
99
                        Topic topic = repository.findById(topicId);
×
100
                        if(topic == null) throw new IllegalArgumentException(TOPIC_EXCEPTION_MESSAGE);
×
101
                        return topic.percentageOfCompletion();
×
102
                });        
103
        }
104

105
        
106
        
107

108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc