001/*
002 * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
003 * Copyright (C) 2000-2010 The Gridarta Developers.
004 *
005 * This program is free software; you can redistribute it and/or modify
006 * it under the terms of the GNU General Public License as published by
007 * the Free Software Foundation; either version 2 of the License, or
008 * (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU General Public License for more details.
014 *
015 * You should have received a copy of the GNU General Public License along
016 * with this program; if not, write to the Free Software Foundation, Inc.,
017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
018 */
019
020package net.sf.gridarta.model.validation;
021
022import net.sf.gridarta.model.archetype.TestArchetype;
023import net.sf.gridarta.model.gameobject.TestGameObject;
024import net.sf.gridarta.model.io.DefaultMapWriter;
025import net.sf.gridarta.model.io.GameObjectParser;
026import net.sf.gridarta.model.io.MapArchObjectParserFactory;
027import net.sf.gridarta.model.io.MapWriter;
028import net.sf.gridarta.model.io.TestMapArchObjectParserFactory;
029import net.sf.gridarta.model.maparchobject.TestMapArchObject;
030import net.sf.gridarta.model.mapmodel.TestMapModelCreator;
031import net.sf.gridarta.model.match.GameObjectMatchers;
032import net.sf.gridarta.model.match.NamedGameObjectMatcher;
033import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher;
034import net.sf.gridarta.model.settings.ProjectSettings;
035import net.sf.gridarta.model.settings.TestProjectSettings;
036import net.sf.gridarta.model.validation.checks.ValidatorFactory;
037import org.jetbrains.annotations.NotNull;
038
039/**
040 * Utility class for helper functions needed be regression tests.
041 * @author Andreas Kirschbaum
042 */
043public class ValidationUtils {
044
045    /**
046     * Private constructor to prevent instantiation.
047     */
048    private ValidationUtils() {
049    }
050
051    /**
052     * Creates a new {@link ValidatorFactory} instance.
053     * @return the new instance
054     */
055    @NotNull
056    public static ValidatorFactory<TestGameObject, TestMapArchObject, TestArchetype> newValidatorFactory() {
057        final ValidatorPreferences validatorPreferences = new TestValidatorPreferences();
058        final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false);
059        final GameObjectMatchers gameObjectMatchers = mapModelCreator.getGameObjectMatchers();
060        gameObjectMatchers.addGameObjectMatcher(new NamedGameObjectMatcher(0, "matcher", "name", false, null, new TypeNrsGameObjectMatcher(1)));
061        final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = mapModelCreator.newGameObjectParser();
062        final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory();
063        final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser);
064        final ProjectSettings projectSettings = new TestProjectSettings();
065        return new ValidatorFactory<TestGameObject, TestMapArchObject, TestArchetype>(validatorPreferences, gameObjectMatchers, projectSettings, mapWriter);
066    }
067
068}