use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FeaturableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final String clazz = "class";
final String setup = "setup";
final FeaturableConfig config = new FeaturableConfig(clazz, setup);
final Xml root = new Xml("test");
root.add(FeaturableConfig.exportClass(clazz));
root.add(FeaturableConfig.exportSetup(setup));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, FeaturableConfig.imports(new Xml(media)));
assertEquals(config, FeaturableConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class BodyConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
final Xml node = root.createChild(BodyConfig.NODE_BODY);
node.writeDouble(BodyConfig.ATT_GRAVITY, 1.0);
node.writeDouble(BodyConfig.ATT_GRAVITY_MAX, 2.0);
root.save(media);
final Body body = new BodyModel(new Services(), new Setup(media));
BodyConfig.exports(root, body);
final BodyConfig config = BodyConfig.imports(new Setup(media));
assertEquals(1.0, config.getGravity());
assertEquals(2.0, config.getGravityMax());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollidableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final int group = 1;
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
final Xml node = root.createChild(CollidableConfig.NODE_COLLIDABLE);
node.writeInteger(CollidableConfig.ATT_GROUP, group);
node.writeString(CollidableConfig.ATT_ACCEPTED, "1%2");
root.save(media);
final CollidableConfig config = CollidableConfig.imports(new Configurer(media));
assertEquals(1, config.getGroup().intValue());
assertIterableEquals(Arrays.asList(Integer.valueOf(1), Integer.valueOf(2)), config.getAccepted());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollidableConfigTest method testDefaultGroup.
/**
* Test with default group.
*/
@Test
void testDefaultGroup() {
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
root.save(media);
assertEquals(CollidableConfig.DEFAULT_GROUP, CollidableConfig.imports(new Configurer(media)).getGroup());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollidableConfigTest method testInvalidGroup.
/**
* Test with invalid group.
*/
@Test
void testInvalidGroup() {
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
final Xml node = root.createChild(CollidableConfig.NODE_COLLIDABLE);
node.writeString(CollidableConfig.ATT_GROUP, "a");
root.save(media);
assertCause(() -> CollidableConfig.imports(new Configurer(media)), NumberFormatException.class);
assertTrue(media.getFile().delete());
}
Aggregations