package com.huskycode.jpaquery.util;

import org.junit.Test;

import java.util.Random;

import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;


/** */
public class RandomizerTest {

    Random any = new Random();
    
    @Test
    public void testGetString() {
        assertThat(Randomizer.getString(),instanceOf(String.class));
          
        int length = Math.abs(any.nextInt());
        String expected = Randomizer.getString(length);

        assertThat(expected,instanceOf(String.class));
        assertThat(expected.length(), equalTo(length));
    }



    @Test
    public void testGetAsciiString() {
        assertThat(Randomizer.getAsciiString(),instanceOf(String.class));

        int length = Math.abs(any.nextInt());
        String expected = Randomizer.getAsciiString(length);

        assertThat(expected,instanceOf(String.class));
        assertThat(expected.length(), equalTo(length));
    }

    @Test
    public void testGetInt() {
        assertThat(Randomizer.getInt(),instanceOf(Integer.class));
    }

    @Test
    public void testGetNonNegativeInt() {
        int expected = Randomizer.getNonNegativeInt();
        assertThat(expected,instanceOf(Integer.class));
        assertTrue(expected >= 0);
    }

    @Test
    public void testGetLong() {
        assertThat(Randomizer.getLong(),instanceOf(Long.class));
    }

    @Test
    public void testGetNonNegativeLong() {
        long expected = Randomizer.getNonNegativeLong();
        assertThat(expected,instanceOf(Long.class));
        assertTrue(expected >= 0);
    }

    @Test
    public void testGetDouble() {
        assertThat(Randomizer.getDouble(),instanceOf(Double.class));
    }

    @Test
    public void testGetBoolean() {
        assertThat(Randomizer.getBoolean(),instanceOf(Boolean.class));
    }
}

@@ -182,16 +182,62 @@
 ualTo;%0D%0A
+import static org.junit.Assert.assertEquals;%0D%0A
 import s
@@ -272,16 +272,16 @@
 tThat;%0D%0A
-
 import s
@@ -365,16 +365,24 @@
 %0D%0A%0D%0A    
+private 
 Random a
@@ -397,24 +397,72 @@
  Random();%0D%0A
+    private static final int MAX_LENGTH = 100;%0D%0A
     %0D%0A    @T
@@ -617,32 +617,42 @@
 abs(any.nextInt(
+MAX_LENGTH
 ));%0D%0A        Str
@@ -995,16 +995,26 @@
 nextInt(
+MAX_LENGTH
 ));%0D%0A   
@@ -1122,32 +1122,32 @@
 tring.class));%0D%0A
-
         assertTh
@@ -1178,32 +1178,116 @@
 ualTo(length));%0D
+%0A%0D%0A        length = 0;%0D%0A        expected = %22%22;%0D%0A        assertEquals(expected, %22%22);%0D
 %0A    %7D%0D%0A%0D%0A    @T

fix test fail