package jdk.java.util;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;

import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 
 * 
 * @since 2018-01-23
 * @author fixalot
 */
public class RandomTest {
//	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(RandomTest.class);

	@Test
	public void testNextInt() {
		for (int i = 0; i < 1000; ++i) {
			Random random = new Random();
			
			int num = random.nextInt(); // int의 최솟값 이상 최댓값 미만 사이의 랜덤값 추출
			logger.debug(String.valueOf(num));
			Assert.assertTrue(Integer.MIN_VALUE <= num && num < Integer.MAX_VALUE);
			
			num = random.nextInt(5); // 0 이상 5 미만 사이의 랜덤값 추출
			logger.debug(String.valueOf(num));
			Assert.assertTrue(0 <= num && num < 5);
		}
	}
	
	@Test
	public void testInts() {
		Random random = new Random();
		IntStream a = random.ints();
		logger.debug(String.valueOf(a.count()));
		a = random.ints(100);
		logger.debug(String.valueOf(a.count()));
	}
	
	/**
	 * List의 요소를 난수로 꺼내기
	 * 
	 * @author fixalot
	 */
	@Test
	public void getRandomElement() {
		List<String> list = new LinkedList<>();
		list.add("하나");
		list.add("둘");
		list.add("셋");
		list.add("넷");
		list.add("다섯");
		list.add("여섯");
		list.add("일곱");
		list.add("여덟");
		list.add("아홉");
		list.add("열");
		for (int i = 0; i < 100; ++i) {
			int randomNumber = new Random().nextInt(list.size());
			String element = list.get(randomNumber);
			Assert.assertNotNull(element);
			Assert.assertFalse(element.isEmpty());
			Assert.assertTrue(element instanceof String);
			if (i == 99) {
				logger.debug(element);
			}
		}
	}
}

@@ -607,46 +607,8 @@
  %EC%B6%94%EC%B6%9C%0A
-%09%09%09logger.debug(String.valueOf(num));%0A
 %09%09%09A
@@ -738,46 +738,8 @@
  %EC%B6%94%EC%B6%9C%0A
-%09%09%09logger.debug(String.valueOf(num));%0A
 %09%09%09A
@@ -786,16 +786,66 @@
 %09%7D%0A%09%7D%0A%09%0A
+%09/**%0A%09 * %EC%96%98%EB%8A%94 %EB%AD%A5%EB%AF%B8?%0A%09 * %0A%09 * @author noritersand%0A%09 */%0A
 %09@Test%0A%09
@@ -938,36 +938,50 @@
 ;%0A%09%09
-logger.debug(String.valueOf(
+Assert.assertEquals(9223372036854775807L, 
 a.co
@@ -986,17 +986,16 @@
 count())
-)
 ;%0A%09%09a = 
@@ -1018,36 +1018,34 @@
 ;%0A%09%09
-logger.debug(String.valueOf(
+Assert.assertEquals(100L, 
 a.co
@@ -1050,17 +1050,16 @@
 count())
-)
 ;%0A%09%7D%0A%09%0A%09
@@ -1414,27 +1414,34 @@
 %0A%09%09%09
-int randomNumber = 
+String element = list.get(
 new 
@@ -1473,51 +1473,8 @@
 e())
-;%0A%09%09%09String element = list.get(randomNumber
 );%0A%09

update test case