use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionCategoryConfigTest method testNoNode.
/**
* Test no node.
*/
@Test
void testNoNode() {
final Xml root = new Xml("categories");
assertTrue(CollisionCategoryConfig.imports(root).isEmpty());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionCategoryConfigTest method testCategory.
/**
* Test category.
*/
@Test
void testCategory() {
final Xml root = new Xml("categories");
CollisionCategoryConfig.exports(root, category);
CollisionCategoryConfig.exports(root, new CollisionCategory("name2", Axis.X, 1, 2, true, Arrays.asList(group)));
final Collection<CollisionCategory> imported = CollisionCategoryConfig.imports(root);
assertEquals(category, imported.iterator().next());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class PathfindableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Map<String, PathData> map = new HashMap<>();
final PathData data = new PathData("category", 1.0, true, Arrays.asList(MovementTile.UP));
map.put(data.getName(), data);
final Xml root = new Xml("test");
root.add(PathfindableConfig.exports(map));
final Media media = Medias.create("pathfindable.xml");
root.save(media);
assertEquals(map, PathfindableConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class PathfindableConfigTest method testWrongMovement.
/**
* Test with wrong movement.
*/
@Test
void testWrongMovement() {
final PathData data = new PathData("category", 1.0, true, EnumSet.noneOf(MovementTile.class));
final Xml path = PathfindableConfig.exportPathData(data);
final Xml movement = path.createChild(PathfindableConfig.NODE_MOVEMENT);
movement.setText("VOID");
final Xml root = new Xml("test");
final Xml node = root.createChild(PathfindableConfig.NODE_PATHFINDABLE);
node.add(path);
final Media media = Medias.create("pathfindable.xml");
root.save(media);
assertCause(() -> PathfindableConfig.imports(new Configurer(media)), IllegalArgumentException.class);
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionCategoryConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Media formulasConfig = UtilConfig.createFormulaConfig(formula);
final Media groupsConfig = UtilConfig.createGroupsConfig(group);
mapCollision.loadCollisions(formulasConfig, groupsConfig);
final Xml root = new Xml("categories");
CollisionCategoryConfig.exports(root, category);
final Media media = Medias.create("Object.xml");
root.save(media);
final Collection<CollisionCategory> imported = CollisionCategoryConfig.imports(new Configurer(media), mapCollision);
assertEquals(category, imported.iterator().next());
assertTrue(formulasConfig.getFile().delete());
assertTrue(groupsConfig.getFile().delete());
assertTrue(media.getFile().delete());
}
Aggregations