Gridarta Editor
DefaultArchetypeSetTest.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.archetypeset;
21 
22 import java.util.Collection;
23 import java.util.Iterator;
37 import org.junit.Assert;
38 import org.junit.Test;
39 
45 
50  @Test
52  final FaceObjects faceObjects = new TestFaceObjects();
53  final ResourceIcons resourceIcons = new ResourceIcons();
54  final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, resourceIcons);
55  final AnimationObjects animationObjects = new TestAnimationObjects();
56  final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(faceObjectProviders, animationObjects);
57  final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet = new DefaultArchetypeSet<>(archetypeFactory, null);
58  archetypeSet.addArchetype(new TestDefaultArchetype("b", faceObjectProviders, animationObjects));
59  archetypeSet.addArchetype(new TestDefaultArchetype("d", faceObjectProviders, animationObjects));
60  archetypeSet.addArchetype(new TestDefaultArchetype("c", faceObjectProviders, animationObjects));
61  archetypeSet.addArchetype(new TestDefaultArchetype("e", faceObjectProviders, animationObjects));
62  archetypeSet.addArchetype(new TestDefaultArchetype("a", faceObjectProviders, animationObjects));
63  final Collection<TestArchetype> archetypes = archetypeSet.getArchetypes();
64  Assert.assertEquals(5, archetypes.size());
65  final Iterator<TestArchetype> it = archetypes.iterator();
66  Assert.assertEquals("b", it.next().getArchetypeName());
67  Assert.assertEquals("d", it.next().getArchetypeName());
68  Assert.assertEquals("c", it.next().getArchetypeName());
69  Assert.assertEquals("e", it.next().getArchetypeName());
70  Assert.assertEquals("a", it.next().getArchetypeName());
71  Assert.assertFalse(it.hasNext());
72  }
73 
74 }
A FaceObjects for regression tests.
Collection< R > getArchetypes()
Returns a read-only collection of all Archetypes.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
An AnimationObjects for regression tests.
A MapArchObject implementation for testing purposes.
A factory for creating Archetype instances.
Base package of all Gridarta classes.
An Archetype implementation for testing purposes.
void testRetainLoadOrder()
Checks that archetypes are returned in load order.
An Exception indicating that an Archetype name is not unique.
AnimationObjects is a container for AnimationObjects.
GameObjects are the objects based on Archetypes found on maps.
FaceObjects is a container for FaceObjects.
void addArchetype(@NotNull R archetype)
Adds an Archetype to this Set.
An ArchetypeFactory implementation for testing purposes.
Provider for faces of GameObjects and Archetypes.
The face is the appearance of an object.
Creates ImageIcon instances from resources.
An Archetype implementation for testing purposes.
A GameObject implementation for testing purposes.
Interface that captures similarities between different ArchetypeSet implementations.