use Tag class instead of String in tests
diff --git a/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java b/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
index 1f8ff55..50cf8ff 100644
--- a/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
+++ b/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
@@ -77,7 +77,7 @@
}
return data instanceof String || data instanceof Boolean || data instanceof Integer
|| data instanceof Long || data instanceof Float || data instanceof Double
- || data instanceof Enum;
+ || data instanceof Enum<?>;
}
/**
@@ -92,7 +92,7 @@
* @return the previous tag associated with the <code>Class</code>
*/
public Tag addClassTag(Class<? extends Object> clazz, String tag) {
- return addClassTag(clazz, new Tag (tag));
+ return addClassTag(clazz, new Tag(tag));
}
public Tag addClassTag(Class<? extends Object> clazz, Tag tag) {
diff --git a/src/test/java/examples/DiceExampleTest.java b/src/test/java/examples/DiceExampleTest.java
index 21e6404..8532dd3 100644
--- a/src/test/java/examples/DiceExampleTest.java
+++ b/src/test/java/examples/DiceExampleTest.java
@@ -60,14 +60,14 @@
public Node representData(Object data) {
Dice dice = (Dice) data;
String value = dice.getA() + "d" + dice.getB();
- return representScalar(new Tag ("!dice"), value);
+ return representScalar(new Tag("!dice"), value);
}
}
}
class DiceConstructor extends SafeConstructor {
public DiceConstructor() {
- this.yamlConstructors.put(new Tag ("!dice"), new ConstructDice());
+ this.yamlConstructors.put(new Tag("!dice"), new ConstructDice());
}
private class ConstructDice extends AbstractConstruct {
@@ -93,7 +93,7 @@
public void testImplicitResolver() throws IOException {
Yaml yaml = new Yaml(new Loader(new DiceConstructor()), new Dumper(new DiceRepresenter(),
new DumperOptions()));
- yaml.addImplicitResolver("!dice", Pattern.compile("\\d+d\\d+"), "123456789");
+ yaml.addImplicitResolver(new Tag("!dice"), Pattern.compile("\\d+d\\d+"), "123456789");
// dump
Map<String, Dice> treasure = (Map<String, Dice>) new HashMap<String, Dice>();
treasure.put("treasure", new Dice(10, 20));
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java
index 7e05cab..c3e981c 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java
@@ -57,7 +57,7 @@
}
car.setWheels(wheels);
Representer representer = new Representer();
- representer.addClassTag(Car.class, "!car");
+ representer.addClassTag(Car.class, new Tag("!car"));
representer.addClassTag(Wheel.class, Tag.MAP);
Dumper dumper = new Dumper(representer, new DumperOptions());
Yaml yaml = new Yaml(dumper);
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java
index 58cbcd1..6873ad4 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java
@@ -36,14 +36,14 @@
String data = "[ 1, 2, 3 ]";
List<Object> list = construct(new CustomConstructor(), data);
assertNotNull(list);
- assertTrue(list.getClass().toString(), list instanceof ArrayList);
+ assertTrue(list.getClass().toString(), list instanceof ArrayList<?>);
}
public void testGetArrayList() {
String data = "[ 1, 2, 3 ]";
List<Object> list = construct(data);
assertNotNull(list);
- assertTrue(list.getClass().toString(), list instanceof ArrayList);
+ assertTrue(list.getClass().toString(), list instanceof ArrayList<?>);
}
public void testDumpList() {
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java
index f474b35..2988e5f 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java
@@ -107,7 +107,7 @@
assertTrue(carYaml1.startsWith("!!org.yaml.snakeyaml.constructor.Car"));
//
Representer representer = new Representer();
- representer.addClassTag(Car.class, "!car");
+ representer.addClassTag(Car.class, new Tag("!car"));
Dumper dumper = new Dumper(representer, new DumperOptions());
yaml = new Yaml(dumper);
String carYaml2 = yaml.dump(car);
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java b/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java
index 2b1ecf6..fd73ecc 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java
@@ -20,6 +20,7 @@
import org.yaml.snakeyaml.Dumper;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Tag;
import org.yaml.snakeyaml.representer.Representer;
public class LongTest extends TestCase {
@@ -53,7 +54,7 @@
DumperOptions options = new DumperOptions();
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
Representer repr = new Representer();
- repr.addClassTag(Long.class, "!!java.lang.Long");
+ repr.addClassTag(Long.class, new Tag("!!java.lang.Long"));
Dumper dumper = new Dumper(repr, options);
Yaml yaml = new Yaml(dumper);
diff --git a/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java b/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java
index d737b51..0bb9ef1 100644
--- a/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java
+++ b/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java
@@ -44,7 +44,7 @@
Loader loader = new Loader(new MyConstructor());
Yaml yaml = new Yaml(loader, dumper);
Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
- yaml.addImplicitResolver(Tag.PREFIX + "Phone", regexp, "0123456789");
+ yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "0123456789");
Phone phone1 = new Phone("12-34-567");
Phone phone2 = new Phone("11-22-333");
Phone phone3 = new Phone("44-55-777");
@@ -66,10 +66,10 @@
Dumper dumper = new Dumper(new PointRepresenter(), new DumperOptions());
Yaml yaml = new Yaml(dumper);
Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
- yaml.addImplicitResolver(Tag.PREFIX + "Phone", regexp, "\0");
+ yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "\0");
Pattern regexp2 = Pattern.compile("x\\d_y\\d");
// try any scalar, and not only those which start with 'x'
- yaml.addImplicitResolver(Tag.PREFIX + "Point", regexp2, null);
+ yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Point"), regexp2, null);
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("a", new Phone("12-34-567"));
map.put("b", new Point(1, 5));
@@ -111,14 +111,14 @@
public Node representData(Object data) {
Phone phone = (Phone) data;
String value = phone.getNumber();
- return representScalar(new Tag (Tag.PREFIX + "Phone"), value);
+ return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
}
}
}
class MyConstructor extends Constructor {
public MyConstructor() {
- this.yamlConstructors.put(new Tag (Tag.PREFIX + "Phone"), new ConstructPhone());
+ this.yamlConstructors.put(new Tag(Tag.PREFIX + "Phone"), new ConstructPhone());
}
private class ConstructPhone extends AbstractConstruct {
@@ -139,7 +139,7 @@
public Node representData(Object data) {
Point phone = (Point) data;
String value = "x" + (int) phone.getX() + "_y" + (int) phone.getY();
- return representScalar(new Tag (Tag.PREFIX + "Point"), value);
+ return representScalar(new Tag(Tag.PREFIX + "Point"), value);
}
}
@@ -147,7 +147,7 @@
public Node representData(Object data) {
Phone phone = (Phone) data;
String value = phone.getNumber();
- return representScalar(new Tag (Tag.PREFIX + "Phone"), value);
+ return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
}
}
}
diff --git a/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java b/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java
index b9561dc..cddcfc8 100644
--- a/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java
+++ b/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java
@@ -62,9 +62,9 @@
DumperOptions options = new DumperOptions();
options.setExplicitStart(true);
Representer repr = new Representer();
- repr.addClassTag(TestObject.class, "!ruby/object:Test::Module::Object");
- repr.addClassTag(Sub1.class, "!ruby/object:Test::Module::Sub1");
- repr.addClassTag(Sub2.class, "!ruby/object:Test::Module::Sub2");
+ repr.addClassTag(TestObject.class, new Tag("!ruby/object:Test::Module::Object"));
+ repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
+ repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
Yaml yaml2 = new Yaml(new Dumper(repr, options));
String output = yaml2.dump(result);
// System.out.println(output);