/*
 * 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.extension.xar.internal;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.xwiki.extension.xar.internal.security.XarSecurityRule;
import org.xwiki.extension.xar.internal.security.XarSecurityTool;
import org.xwiki.security.authorization.Right;

import static org.mockito.Mockito.mock;

public class XarSecurityRuleTest
{
    private XarSecurityTool xarSecurityTool;

    private XarSecurityRule adminSimple;
    private XarSecurityRule adminSimple2;
    private XarSecurityRule commentSimple;
    private XarSecurityRule adminExtended;

    @Before
    public void setUp()
    {
        xarSecurityTool = mock(XarSecurityTool.class);

        // Create some XarSecurityRules that will be compared
        adminSimple = new XarSecurityRule(Right.ADMIN, true, xarSecurityTool);
        adminSimple2 = new XarSecurityRule(Right.ADMIN, true, xarSecurityTool);
        commentSimple = new XarSecurityRule(Right.COMMENT, true, xarSecurityTool);
        adminExtended = new XarSecurityRule(Right.ADMIN, false, xarSecurityTool);
    }

    @Test
    public void testEquals()
    {
        // Test the identity
        Assert.assertEquals(adminSimple, adminSimple);
        Assert.assertEquals(adminSimple, adminSimple2);

        // Test with different rights
        Assert.assertNotEquals(adminSimple, commentSimple);

        // Test with a simple / extended rule
        Assert.assertNotEquals(adminSimple, adminExtended);
    }

    @Test
    public void testHashCode()
    {
        // Test the identity
        Assert.assertEquals(adminSimple.hashCode(), adminSimple.hashCode());
        Assert.assertEquals(adminSimple.hashCode(), adminSimple2.hashCode());

        // Test with different rights
        Assert.assertNotEquals(adminSimple.hashCode(), commentSimple.hashCode());

        // Test with a simple / extended rule
        Assert.assertNotEquals(adminSimple.hashCode(), adminExtended.hashCode());
    }
}

@@ -951,39 +951,30 @@
 nit.
-Assert;%0Aimport org.junit
+jupiter.api
 .Before
+Each
 ;%0Aim
@@ -988,16 +988,28 @@
 g.junit.
+jupiter.api.
 Test;%0Aim
@@ -1186,16 +1186,141 @@
 Right;%0A%0A
+import static org.junit.jupiter.api.Assertions.assertEquals;%0Aimport static org.junit.jupiter.api.Assertions.assertNotEquals;%0A
 import s
@@ -1352,23 +1352,16 @@
 .mock;%0A%0A
-public 
 class Xa
@@ -1607,27 +1607,24 @@
  @Before
+Each
 %0A   
- public
  void se
@@ -2090,39 +2090,32 @@
 %0A%0A    @Test%0A    
-public 
 void testEquals(
@@ -2151,39 +2151,32 @@
 dentity%0A        
-Assert.
 assertEquals(adm
@@ -2199,39 +2199,32 @@
 imple);%0A        
-Assert.
 assertEquals(adm
@@ -2287,39 +2287,32 @@
  rights%0A        
-Assert.
 assertNotEquals(
@@ -2387,39 +2387,32 @@
 ed rule%0A        
-Assert.
 assertNotEquals(
@@ -2465,15 +2465,8 @@
     
-public 
 void
@@ -2516,39 +2516,32 @@
 dentity%0A        
-Assert.
 assertEquals(adm
@@ -2590,31 +2590,24 @@
 ));%0A        
-Assert.
 assertEquals
@@ -2696,39 +2696,32 @@
  rights%0A        
-Assert.
 assertNotEquals(
@@ -2830,15 +2830,8 @@
     
-Assert.
 asse

Upgrade test to JUnit5