package eu.fraho.spring.securityJwt;

import eu.fraho.spring.securityJwt.dto.TimeWithPeriod;
import org.junit.Assert;
import org.junit.Test;

import java.util.concurrent.TimeUnit;

public class TestTimeWithPeriod {
    @Test
    public void testToString() {
        Assert.assertEquals("1 DAYS", new TimeWithPeriod(1, TimeUnit.DAYS).toString());
        Assert.assertEquals("7 HOURS", new TimeWithPeriod(7, TimeUnit.HOURS).toString());
    }

    @Test
    public void testEquals() {
        Assert.assertTrue(new TimeWithPeriod(1, TimeUnit.DAYS).equals(new TimeWithPeriod(24, TimeUnit.HOURS)));
        Assert.assertFalse(new TimeWithPeriod(1, TimeUnit.HOURS).equals(new TimeWithPeriod(3601, TimeUnit.SECONDS)));
        Assert.assertFalse(new TimeWithPeriod(1, TimeUnit.HOURS).equals(null));
        Assert.assertFalse(new TimeWithPeriod(1, TimeUnit.HOURS).equals(new Object()));
    }

    @Test
    public void testToSeconds() {
        Assert.assertEquals(3600, new TimeWithPeriod(1, TimeUnit.HOURS).toSeconds());
        Assert.assertEquals(86_400, new TimeWithPeriod(1, TimeUnit.DAYS).toSeconds());
    }
}

@@ -428,32 +428,138 @@
 ring());%0A    %7D%0A%0A
+    @SuppressWarnings(%22ObjectEqualsNull%22) // is intended; check for correct null handling within %22equals%22%0A
     @Test%0A    pu
@@ -1210,11 +1210,686 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testHashcode() %7B%0A        Assert.assertEquals(new TimeWithPeriod(60, TimeUnit.MINUTES).hashCode(), new TimeWithPeriod(1, TimeUnit.HOURS).hashCode());%0A        Assert.assertNotEquals(new TimeWithPeriod(1_000_000, TimeUnit.SECONDS).hashCode(), new TimeWithPeriod(1_000_001, TimeUnit.SECONDS).toSeconds());%0A    %7D%0A%0A    @Test%0A    public void testValues() %7B%0A        TimeWithPeriod testee = new TimeWithPeriod(60, TimeUnit.MINUTES);%0A        Assert.assertEquals(60, testee.getQuantity());%0A        Assert.assertEquals(TimeUnit.MINUTES, testee.getTimeUnit());%0A        Assert.assertEquals(60, new TimeWithPeriod(1_000_001, TimeUnit.SECONDS).toSeconds());%0A    %7D
 %0A%7D%0A

add a missing testcase for TimeWithPeriod