/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.notifications.internal;

import org.junit.Before;
import org.junit.Test;
import org.xwiki.eventstream.Event;
import org.xwiki.model.reference.DocumentReference;

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

/**
 * Unit tests for {@link SimilarityCalculator}.
 */
public class SimilarityCalculatorTest
{
    private SimilarityCalculator sq;

    @Before
    public void setUp() throws Exception
    {
        this.sq = new SimilarityCalculator();
    }

    @Test
    public void testComputeSimilarity() throws Exception
    {
        DocumentReference document =
                new DocumentReference("xwiki", "somewhere", "something");
        String group = "myGroupId";
        String type = "type";

        Event event1 = mock(Event.class);
        Event event2 = mock(Event.class);

        when(event1.getDocument()).thenReturn(document);
        when(event2.getDocument()).thenReturn(document);

        when(event1.getGroupId()).thenReturn(group);
        when(event2.getGroupId()).thenReturn(group);

        assertEquals(SimilarityCalculator.SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES, this.sq.computeSimilarity(event1, event2));

        when(event2.getGroupId()).thenReturn("somethingElse");

        assertEquals(SimilarityCalculator.NO_SIMILARITY, this.sq.computeSimilarity(event1, event2));

        when(event1.getType()).thenReturn(type);
        when(event2.getType()).thenReturn(type);

        assertEquals(SimilarityCalculator.SAME_DOCUMENT_AND_TYPE, this.sq.computeSimilarity(event1, event2));

        // Even if the group is the same, if they share the same type, we consider not as the same groupid
        when(event2.getGroupId()).thenReturn(group);
        assertEquals(SimilarityCalculator.SAME_DOCUMENT_AND_TYPE, this.sq.computeSimilarity(event1, event2));
    }
}

@@ -947,22 +947,38 @@
 g.junit.
+jupiter.api.
 Before
+Each
 ;%0Aimport
@@ -988,16 +988,28 @@
 g.junit.
+jupiter.api.
 Test;%0Aim
@@ -1123,14 +1123,30 @@
 nit.
+jupiter.api.
 Assert
+ions
 .ass
@@ -1289,16 +1289,36 @@
 lator%7D.%0A
+ *%0A * @version $Id$%0A
  */%0Apubl
@@ -1402,16 +1402,20 @@
  @Before
+Each
 %0A    pub
@@ -1525,25 +1525,14 @@
     
-public void testC
+void c
 ompu
@@ -1545,33 +1545,16 @@
 larity()
- throws Exception
 %0A    %7B%0A 
@@ -2033,24 +2033,24 @@
 rn(group);%0A%0A
-
         asse
@@ -2126,16 +2126,28 @@
 T_TYPES,
+%0A           
  this.sq

Convert to JUnit5 and apply best practices