use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FovableConfigTest method testExportsImportsNoNode.
/**
* Test exports imports without node.
*/
@Test
void testExportsImportsNoNode() {
final Xml root = new Xml("test");
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(0, FovableConfig.imports(new Xml(media)));
assertEquals(0, FovableConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionGroupConfigTest method testExportsImportsMap.
/**
* Test with map.
*/
@Test
void testExportsImportsMap() {
final Xml root = new Xml("groups");
CollisionGroupConfig.exports(root, group);
final Media groupsConfig = Medias.create("groups.xml");
root.save(groupsConfig);
final Media formulasConfig = UtilConfig.createFormulaConfig(formula);
mapCollision.loadCollisions(formulasConfig, groupsConfig);
final CollisionGroupConfig groups = CollisionGroupConfig.imports(groupsConfig);
assertEquals(group, groups.getGroups().values().iterator().next());
assertTrue(groupsConfig.getFile().delete());
assertTrue(formulasConfig.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionGroupConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Xml root = new Xml("groups");
CollisionGroupConfig.exports(root, group);
final Media config = Medias.create("groups.xml");
root.save(config);
final CollisionGroupConfig imported = CollisionGroupConfig.imports(config);
assertEquals(group, imported.getGroups().values().iterator().next());
assertEquals(group, imported.getGroup("group"));
assertTrue(config.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionRangeConfigTest method testInvalidAxis.
/**
* Test with invalid axis.
*/
@Test
void testInvalidAxis() {
final Xml root = new Xml("ranges");
final CollisionRange range = new CollisionRange(Axis.X, 0, 1, 2, 3);
CollisionRangeConfig.exports(root, range);
root.getChildXml(CollisionRangeConfig.NODE_RANGE).writeString(CollisionRangeConfig.ATT_AXIS, "void");
assertThrows(() -> CollisionRangeConfig.imports(root.getChild(CollisionRangeConfig.NODE_RANGE)), XmlReader.ERROR_ENUM + "void");
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class UtilConfig method createFormulaConfig.
/**
* Create formula configuration.
*
* @param formulas The collision formulas.
* @return The formula configuration.
*/
public static Media createFormulaConfig(CollisionFormula... formulas) {
final Media media = Medias.create("formulas.xml");
final Xml root = new Xml("formulas");
for (final CollisionFormula formula : formulas) {
CollisionFormulaConfig.exports(root, formula);
}
root.save(media);
return media;
}
Aggregations