@@ -0,0 +1,3017 @@
+/*%0A * Copyright 2016-2017 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage de.vorb.platon.web.api.controllers;%0A%0Aimport de.vorb.platon.jooq.tables.records.CommentsRecord;%0Aimport de.vorb.platon.model.CommentStatus;%0Aimport de.vorb.platon.persistence.CommentRepository;%0Aimport de.vorb.platon.persistence.ThreadRepository;%0Aimport de.vorb.platon.security.RequestVerifier;%0Aimport de.vorb.platon.web.api.common.CommentConverter;%0Aimport de.vorb.platon.web.api.common.CommentFilters;%0Aimport de.vorb.platon.web.api.common.InputSanitizer;%0Aimport de.vorb.platon.web.api.json.CommentJson;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0A%0Aimport java.time.Clock;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.mockito.Matchers.eq;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class CommentControllerTest %7B%0A%0A    private CommentController commentController;%0A%0A    private Clock clock = Clock.systemUTC();%0A%0A    @Mock%0A    private ThreadRepository threadRepository;%0A    @Mock%0A    private CommentRepository commentRepository;%0A%0A    @Mock%0A    private CommentConverter commentConverter;%0A    @Mock%0A    private RequestVerifier requestVerifier;%0A    @Mock%0A    private InputSanitizer inputSanitizer;%0A    @Mock%0A    private CommentFilters commentFilters;%0A%0A    @Mock%0A    private CommentJson commentJson;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        commentController = new CommentController(clock, threadRepository, commentRepository, commentConverter,%0A                requestVerifier, inputSanitizer, commentFilters);%0A    %7D%0A%0A    @Test%0A    public void getCommentByIdReturnsPublicComment() throws Exception %7B%0A%0A        final long commentId = 4711;%0A        final CommentsRecord publicRecord =%0A                new CommentsRecord()%0A                        .setId(commentId)%0A                        .setText(%22Text%22)%0A                        .setStatus(%22PUBLIC%22);%0A%0A        when(commentRepository.findById(eq(commentId))).thenReturn(publicRecord);%0A        when(commentConverter.convertRecordToJson(eq(publicRecord))).thenReturn(commentJson);%0A%0A        assertThat(commentController.getCommentById(commentId)).isSameAs(commentJson);%0A%0A        verify(commentRepository).findById(eq(commentId));%0A        verify(commentConverter).convertRecordToJson(eq(publicRecord));%0A    %7D%0A%7D%0A

Test CommentController.getCommentById()