/*-
 *  Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
 * 
 *  This file is part of CityDoctor2.
 *
 *  CityDoctor2 is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  CityDoctor2 is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with CityDoctor2.  If not, see <https://www.gnu.org/licenses/>.
 */
package de.hft.stuttgart.citydoctor2.check;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.junit.Test;

import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;

public class FilterTest {

	@Test
	public void testFilterExclude() throws CityGmlParseException, IOException, InvalidGmlFileException {
		ValidationConfiguration config = ValidationConfiguration
				.loadValidationConfig("src/test/resources/testConfigWithExclude.yml");
		CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/testarea.gml",
				new ParserConfiguration(8, false));
		Checker c = new Checker(config, model);
		c.runChecks();

		Building b = model.getBuildings().get(0);
		Geometry geom = b.getGeometries().get(0);

		assertFalse(geom.hasCheckResults());

		TransportationObject to = model.getTransportation().get(0);
		Geometry geom2 = to.getGeometries().get(0);

		assertTrue(geom2.getPolygons().get(0).hasCheckResults());
	}

	@Test
	public void testFilterInclude() throws CityGmlParseException, IOException, InvalidGmlFileException {
		ValidationConfiguration config = ValidationConfiguration
				.loadValidationConfig("src/test/resources/testConfigWithInclude.yml");
		CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/testarea.gml",
				new ParserConfiguration(8, false));
		Checker c = new Checker(config, model);
		c.runChecks();

		Building b = model.getBuildings().get(0);
		Geometry geom = b.getGeometries().get(0);

		assertFalse(geom.hasCheckResults());

		TransportationObject to = model.getTransportation().get(0);
		Geometry geom2 = to.getGeometries().get(0);

		assertTrue(geom2.getPolygons().get(0).hasCheckResults());

	}

}
