use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionConstraintConfigTest method testExportsImportsEmptyConstraints.
/**
* Test with empty constraint.
*/
@Test
void testExportsImportsEmptyConstraints() {
final Xml root = new Xml("constraint");
final CollisionConstraint constraint = new CollisionConstraint();
CollisionConstraintConfig.exports(root, constraint);
assertEquals(constraint, CollisionConstraintConfig.imports(root));
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionFormulaConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Xml root = new Xml("formula");
CollisionFormulaConfig.exports(root, formula);
final Media config = Medias.create("formulas.xml");
root.save(config);
final CollisionFormulaConfig imported = CollisionFormulaConfig.imports(config);
assertEquals("formula", imported.getFormulas().keySet().iterator().next());
assertEquals(formula, imported.getFormula("formula"));
assertTrue(config.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionFunctionConfigTest method testImportFunctionInvalid.
/**
* Test import with invalid function.
*/
@Test
void testImportFunctionInvalid() {
final Xml root = new Xml("function");
final CollisionFunction function = new CollisionFunctionLinear(2.0, 3.0);
CollisionFunctionConfig.exports(root, function);
root.getChildXml(CollisionFunctionConfig.FUNCTION).writeString(CollisionFunctionConfig.TYPE, "void");
assertThrows(() -> CollisionFunctionConfig.imports(root), XmlReader.ERROR_ENUM + "void");
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionFunctionConfigTest method testFunction.
/**
* Test exports imports.
*/
@Test
void testFunction() {
final Xml root = new Xml("function");
final CollisionFunction function = new CollisionFunctionLinear(2.0, 3.0);
CollisionFunctionConfig.exports(root, function);
final CollisionFunction imported = CollisionFunctionConfig.imports(root);
assertEquals(function, imported);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class TransitionsConfig method exportTiles.
/**
* Export all tiles for the transition.
*
* @param nodeTransition The transition node (must not be <code>null</code>).
* @param tiles The transition tiles (must not be <code>null</code>).
*/
private static void exportTiles(Xml nodeTransition, Collection<Integer> tiles) {
for (final Integer tile : tiles) {
final Xml nodeTile = TileConfig.exports(tile.intValue());
nodeTransition.add(nodeTile);
}
}
Aggregations