/*
 * Copyright (c) 2012-2017, John Campbell and other contributors.  All rights reserved.
 *
 * This file is part of Tectonicus. It is subject to the license terms in the LICENSE file found in
 * the top-level directory of this distribution.  The full list of project contributors is contained
 * in the AUTHORS file found in the same location.
 *
 */

package tectonicus.configuration;

import static org.junit.Assert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.Is.*;

import java.nio.file.Paths;

import org.junit.Test;

import tectonicus.raw.Player;

public class PlayerFilterTests
{
	@Test
	public void testCreatePlayerFilter() throws Exception
	{
		PlayerFilter pf = new PlayerFilter(PlayerFilterType.Whitelist, Paths.get("src/test/resources/whitelist.json"), Paths.get("src/test/resources/Canned.basic"));
		assertThat(pf.toString(), is(equalTo("Whitelist: src\\test\\resources\\whitelist.json")));
	}
	
	@Test
	public void passesFilterWithFilterTypeAll() throws Exception
	{
		PlayerFilter pf = new PlayerFilter();
		boolean pass = pf.passesFilter(new Player("", "", ""));
		assertThat(pass, is(equalTo(true)));
	}
	
	@Test
	public void passesFilterWithJsonWhitelist() throws Exception
	{
		PlayerFilter pf = new PlayerFilter(PlayerFilterType.Whitelist, Paths.get("src/test/resources/whitelist.json"), Paths.get("src/test/resources/Canned.basic"));
		boolean pass = pf.passesFilter(new Player("androidz", "", ""));
		assertThat(pass, is(equalTo(true)));
	}
	
	@Test
	public void passesFilterWithTxtWhitelist() throws Exception
	{
		PlayerFilter pf = new PlayerFilter(PlayerFilterType.Whitelist, Paths.get("src/test/resources/whitelist.txt"), Paths.get("src/test/resources/Canned.basic"));
		boolean pass = pf.passesFilter(new Player("androidz", "", ""));
		assertThat(pass, is(equalTo(true)));
	}
	
	@Test
	public void createPlayerFilterWithDefaultWhitelist() throws Exception
	{
		PlayerFilter pf = new PlayerFilter(PlayerFilterType.Whitelist, Paths.get("."), Paths.get("src/test/resources/Canned.basic"));
		assertThat(pf.toString(), is(equalTo("Whitelist: .")));
		assertThat(pf.passesFilter(new Player("androidz", "", "")), is(equalTo(true)));
	}
}

@@ -441,58 +441,8 @@
 t;%0D%0A
-import static org.hamcrest.core.IsEqual.equalTo;%0D%0A
 impo
@@ -476,16 +476,16 @@
 .Is.*;%0D%0A
+
 %0D%0Aimport
@@ -812,38 +812,32 @@
 resources/Canned
-.basic
 %22));%0D%0A%09%09assertTh
@@ -853,32 +853,24 @@
 tring(), is(
-equalTo(
 %22Whitelist: 
@@ -908,17 +908,16 @@
 .json%22))
-)
 ;%0D%0A%09%7D%0D%0A%09
@@ -1111,39 +1111,30 @@
 at(pass, is(
-equalTo(
 true))
-)
 ;%0D%0A%09%7D%0D%0A%09%0D%0A%09@
@@ -1347,38 +1347,32 @@
 resources/Canned
-.basic
 %22));%0D%0A%09%09boolean 
@@ -1446,39 +1446,30 @@
 at(pass, is(
-equalTo(
 true))
-)
 ;%0D%0A%09%7D%0D%0A%09%0D%0A%09@
@@ -1680,38 +1680,32 @@
 resources/Canned
-.basic
 %22));%0D%0A%09%09boolean 
@@ -1779,39 +1779,30 @@
 at(pass, is(
-equalTo(
 true))
-)
 ;%0D%0A%09%7D%0D%0A%09%0D%0A%09@
@@ -2004,14 +2004,8 @@
 nned
-.basic
 %22));
@@ -2037,24 +2037,16 @@
 g(), is(
-equalTo(
 %22Whiteli
@@ -2053,17 +2053,16 @@
 st: .%22))
-)
 ;%0D%0A%09%09ass
@@ -2125,23 +2125,14 @@
  is(
-equalTo(
 true))
-)
 ;%0D%0A%09

Fix up tests a bit