package com.atlassian.stash.internal.notification.commit.handlers;

import com.atlassian.bitbucket.comment.Comment;
import com.atlassian.bitbucket.notification.commit.CommitDiscussionCommentRepliedNotification;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class CommitDiscussionCommentRepliedNotificationHandlerTest {

    @InjectMocks
    private CommitDiscussionCommentRepliedNotificationHandler notificationHandler;

    @Test
    public void testContextValues() {
        CommitDiscussionCommentRepliedNotification notification = mock(CommitDiscussionCommentRepliedNotification.class);
        CommitDiscussionNotificationTestUtils.setupNotificationComment(notification);

        Comment parent = mock(Comment.class);
        when(notification.getParent()).thenReturn(parent);

        Map<String, Object> context = notificationHandler.getContext(notification);

        CommitDiscussionNotificationTestUtils.assertNotificationComment(notification, context);
        assertEquals("Same parent", notification.getParent(), context.get("parent"));
    }
}
