package loc;

import loc.filter.*;
import loc.filter.filters.aggregate.And;
import loc.filter.filters.aggregate.Or;
import loc.filter.filters.FileExtensionFilter;
import loc.filter.filters.time.ModifiedLater;
import loc.filter.serializers.aggregate.OrFilterSerializer;
import org.junit.Test;

import java.nio.file.Path;
import java.nio.file.Paths;

import static org.junit.Assert.*;

public class ParserTest {
	@Test (expected = FilterSerializeException.class)
	public void parseEmpty() throws Exception {
		OrFilterSerializer.getInstance().serialize("");
	}
/* parenthesis are only for filter sequences now (used only in AggregateFilter)
	@Test (expected = FilterParser.ParseException.class)
	public void parseEmptyParenthesis() throws Exception {
		FilterParser.parseOr("()");
	}

	@Test (expected = FilterParser.ParseException.class)
	public void parseWrongParenthesisCount() throws Exception {
		FilterParser.parseAnd("((()");
	}

	@Test (expected = FilterParser.ParseException.class)
	public void parseAndEmpty() throws Exception {
		FilterParser.parseAnd("(() () ())");
	}

	@Test (expected = FilterParser.ParseException.class)
	public void parseEmptyCommaSeparatedSequence() throws Exception {
		FilterParser.parseAnd("(   )");
	}
*/

	@Test (expected = FilterSerializeException.class)
	public void parse10EmptyLines() throws Exception {
		ConfigFileReader.readFilters(Paths.get("tests/input/10lines"));
	}

	@Test
	public void parse6FiltersInputFile() throws Exception {
		Path config = Paths.get("tests/input/6filters.input");
		Filter[] actualFilters = ConfigFileReader.readFilters(config);
		assertEquals(6, actualFilters.length);
		Filter extensionFilter = new FileExtensionFilter("input");
		Filter timeFilter = new ModifiedLater(1487311235);
		Filter[] expectedFilters = {
				extensionFilter,
				timeFilter,
				new And(new Filter[]{
						timeFilter
				}),
				new Or(new Filter[]{
						timeFilter, timeFilter
				}),
				new And(new Filter[]{
						new Or(new Filter[]{
								new And(new Filter[]{
										timeFilter
								})
						})
				}),
				new And(new Filter[]{
						extensionFilter,
						timeFilter,
						new Or(new Filter[]{
								timeFilter,
								extensionFilter
						})
				})
		};
		for (int i = 0; i < actualFilters.length; i++) {
			assertEquals(expectedFilters[i].toString(), actualFilters[i].toString());
		}
	}
}
@@ -555,690 +555,8 @@
 ;%0A%09%7D
-%0A/* parenthesis are only for filter sequences now (used only in AggregateFilter)%0A%09@Test (expected = FilterParser.ParseException.class)%0A%09public void parseEmptyParenthesis() throws Exception %7B%0A%09%09FilterParser.parseOr(%22()%22);%0A%09%7D%0A%0A%09@Test (expected = FilterParser.ParseException.class)%0A%09public void parseWrongParenthesisCount() throws Exception %7B%0A%09%09FilterParser.parseAnd(%22((()%22);%0A%09%7D%0A%0A%09@Test (expected = FilterParser.ParseException.class)%0A%09public void parseAndEmpty() throws Exception %7B%0A%09%09FilterParser.parseAnd(%22(() () ())%22);%0A%09%7D%0A%0A%09@Test (expected = FilterParser.ParseException.class)%0A%09public void parseEmptyCommaSeparatedSequence() throws Exception %7B%0A%09%09FilterParser.parseAnd(%22(   )%22);%0A%09%7D%0A*/
 %0A%0A%09@

Remove commented code