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

import com.atlassian.bitbucket.notification.pull.PullRequestReviewedNotification;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

import static org.mockito.Mockito.mock;

@RunWith(MockitoJUnitRunner.class)
public class PullRequestReviewedNotificationHandlerTest {

    @InjectMocks
    private PullRequestReviewedNotificationHandler notificationHandler;

    @Test
    public void testContextValues() {
        PullRequestReviewedNotification notification = mock(PullRequestReviewedNotification.class);
        PullRequestNotificationTestUtils.setupNotification(notification);

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

        PullRequestNotificationTestUtils.assertNotification(notification, context);
    }

    @Test
    public void testEmailContents() throws InvocationTargetException, NoSuchMethodException, InstantiationException,
                                           IllegalAccessException {
        PullRequestReviewedNotification notification = mock(PullRequestReviewedNotification.class);

        PullRequestNotificationTestUtils.assertMailHandler(PullRequestReviewedNotificationHandler::new, notification,
                PullRequestReviewedNotificationHandler.TEMPLATE);
    }
}
