package com.drumonii.loltrollbuild.util;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static com.drumonii.loltrollbuild.util.RandomizeUtil.*;
import static org.assertj.core.api.Assertions.assertThat;

@RunWith(JUnit4.class)
public class RandomizeUtilTest {

	@Test
	public void getsRandomFromList() {
		List<String> strings = List.of("string 1", "string 2");
		assertThat(getRandom(strings)).isIn(strings);

		try {
			getRandom(new ArrayList<>());
		} catch (Exception e) {
			assertThat(e).isInstanceOf(IllegalArgumentException.class);
		}
	}

	@Test
	public void getsRandomFromSet() {
		Set<Integer> integers = Set.of(1, 2);
		assertThat(getRandom(integers)).isIn(integers);

		try {
			getRandom(new HashSet<>());
		} catch (Exception e) {
			assertThat(e).isInstanceOf(IllegalArgumentException.class);
		}
	}

	@Test
	public void getsRandomFromNull() {
		try {
			getRandom(null);
		} catch (Exception e) {
			assertThat(e).isInstanceOf(IllegalArgumentException.class);
		}
	}

	@Test
	public void getsRandomsFromList() {
		List<String> strings = List.of("string 1", "string 2");
		assertThat(getRandoms(strings, 1)).containsAnyElementsOf(strings)
				.hasSize(1);
		assertThat(getRandoms(strings, strings.size() + 1)).containsAnyElementsOf(strings)
				.hasSize(2);
	}

	@Test
	public void getsRandomsFromSet() {
		Set<Integer> integers = Set.of(1, 2);
		assertThat(getRandoms(integers, 1)).containsAnyElementsOf(integers)
				.hasSize(1);
		assertThat(getRandoms(integers, integers.size() + 1)).containsAnyElementsOf(integers)
				.hasSize(2);
	}

	@Test
	public void getsRandomsFromNull() {
		try {
			getRandoms(null, 1);
		} catch (Exception e) {
			assertThat(e).isInstanceOf(IllegalArgumentException.class);
		}
	}

	@Test
	public void getsRandomLong() {
		assertThat(getRandomLong()).isNotZero();
	}

	@Test
	public void getsRandomInt() {
		assertThat(getRandomInt()).isNotZero();
	}

}
@@ -334,26 +334,17 @@
 ertions.
-assertThat
+*
 ;%0A%0A@RunW
@@ -547,143 +547,8 @@
 gs);
-%0A%0A%09%09try %7B%0A%09%09%09getRandom(new ArrayList%3C%3E());%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09assertThat(e).isInstanceOf(IllegalArgumentException.class);%0A%09%09%7D
 %0A%09%7D%0A
@@ -684,77 +684,258 @@
 s);%0A
-%0A%09%09try %7B%0A%09%09%09getRandom(new HashSet%3C%3E());%0A%09%09%7D catch (Exception e) %7B
+%09%7D%0A%0A%09@Test%0A%09public void getsRandomFromEmptyCollection() %7B%0A%09%09assertThatExceptionOfType(IllegalArgumentException.class)%0A%09%09%09%09.isThrownBy(() -%3E getRandom(new ArrayList%3C%3E()))%0A%09%09%09%09.withMessage(%22Unable to get a random element from an empty Collection%22);%0A
 %0A%09%09
-%09
 asse
@@ -940,32 +940,31 @@
 sertThat
-(e).isInstanceOf
+ExceptionOfType
 (Illegal
@@ -991,181 +991,358 @@
 ass)
-;%0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A%09public void getsRandomFromNull() %7B%0A%09%09try %7B%0A%09%09%09getRandom(null);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09assertThat(e).isInstanceOf(IllegalArgumentException.class);%0A%09%09%7D
+%0A%09%09%09%09.isThrownBy(() -%3E getRandom(new HashSet%3C%3E()))%0A%09%09%09%09.withMessage(%22Unable to get a random element from an empty Collection%22);%0A%09%7D%0A%0A%09@Test%0A%09public void getsRandomFromNull() %7B%0A%09%09assertThatExceptionOfType(IllegalArgumentException.class)%0A%09%09%09%09.isThrownBy(() -%3E getRandom(null))%0A%09%09%09%09.withMessage(%22Unable to get a random element from an empty Collection%22);
 %0A%09%7D%0A
@@ -1964,130 +1964,183 @@
 %7B%0A%09%09
-try %7B%0A%09%09%09getRandoms(null, 1);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09assertThat(e).isInstanceOf(IllegalArgumentException.class);%0A%09%09%7D
+assertThatExceptionOfType(IllegalArgumentException.class)%0A%09%09%09%09.isThrownBy(() -%3E getRandoms(null, 1))%0A%09%09%09%09.withMessage(%22Unable to get random elements from an null Collection%22);
 %0A%09%7D%0A
@@ -2311,8 +2311,9 @@
 );%0A%09%7D%0A%0A%7D
+%0A

Simplify assertions with assertThatExceptionOfType