public void testDefaultRepresenter() { Car car = new Car(); car.setPlate("12-XP-F4"); List<Wheel> wheels = new ArrayList<Wheel>(); for (int i = 1; i < 6; i++) { Wheel wheel = new Wheel(); wheel.setId(i); wheels.add(wheel); } car.setWheels(wheels); assertEquals(Util.getLocalResource("constructor/car-with-tags.yaml"), new Yaml().dump(car)); }
public void testDumpClassTag() { Car car = new Car(); car.setPlate("12-XP-F4"); List<Wheel> wheels = new ArrayList<Wheel>(); for (int i = 1; i < 6; i++) { Wheel wheel = new Wheel(); wheel.setId(i); wheels.add(wheel); } car.setWheels(wheels); Representer representer = new Representer(); representer.addClassTag(Car.class, new Tag("!car")); representer.addClassTag(Wheel.class, Tag.MAP); Yaml yaml = new Yaml(representer); String output = yaml.dump(car); assertEquals(Util.getLocalResource("constructor/car-without-tags.yaml"), output); }