use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectEntityTest method testMap.
@Test
public void testMap() throws Exception {
final Integer subjectId = 5;
final String subjectName = "Test subject";
final Integer subjectUserId = 1;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
Mockito.when(subjectModel.getId()).thenReturn(subjectId);
Mockito.when(subjectModel.getName()).thenReturn(subjectName);
Mockito.when(subjectModel.getTopics()).thenReturn(new ModelsListEmpty());
Mockito.when(subjectModel.getUser()).thenReturn(new UserModelEmpty(subjectUserId));
Mockito.when(subjectModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty());
Mockito.when(subjectModel.getIssues()).thenReturn(new ModelsListEmpty());
final SubjectEntity subjectEntity = new SubjectEntity();
subjectEntity.map(subjectModel);
Assert.assertEquals(subjectId, subjectEntity.getId());
Assert.assertEquals(subjectName, subjectEntity.getName());
Assert.assertEquals(subjectUserId, subjectEntity.getUserId());
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsController method create.
@GetMapping("create/")
public String create(Model model, @PathVariable("subjectId") Integer subjectId) {
final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
final TopicDto topic = new TopicDto();
setCreateBehaviour(model);
model.addAttribute("topic", topic);
model.addAttribute("subjectId", subjectId);
return "topics/form";
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsController method read.
@GetMapping("{topicId}")
public String read(Model model, @PathVariable("subjectId") Integer subjectId, @PathVariable("topicId") Integer topicId) {
final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
final TopicModelInterface topicModel = getTopicModel(topicId, subjectId);
model.addAttribute("topic", topicModel);
model.addAttribute("subjectId", subjectId);
return "topics/view";
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsController method update.
@GetMapping("update/{topicId}/")
public String update(Model model, @PathVariable Integer topicId, @PathVariable("subjectId") Integer subjectId) {
final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
final TopicModelInterface topicModel = this.getTopicModel(topicId, subjectId);
final TopicDto topic = new TopicDto();
topic.map(topicModel);
setUpdateBehaviour(model);
model.addAttribute("topic", topic);
model.addAttribute("subjectId", subjectId);
return "topics/form";
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsController method delete.
@PostMapping("delete/{topicId}")
public String delete(Model model, @PathVariable("topicId") Integer topicId, @PathVariable("subjectId") Integer subjectId) {
final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
final TopicModelInterface topicModel = getTopicModel(topicId, subjectId, topicsOptionsBuilder.forDelete());
if (questionsService.findByTopic(topicModel).isEmpty()) {
topicsService.delete(topicModel);
} else {
topicsService.delete(topicModel, this.topicsOptionsBuilder.forDelete());
}
return "redirect:/personal/subjects/" + subjectId + "/topics/";
}
Aggregations