diff --git a/pom.xml b/pom.xml
index 69c0a87..6aaaf28 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.ljunggren
+ io.ljunggren
yaml-utils
0.0.1-SNAPSHOT
jar
diff --git a/src/main/java/com/ljunggren/yamlUtils/YamlUtils.java b/src/main/java/com/ljunggren/yamlUtils/YamlUtils.java
deleted file mode 100644
index e45386f..0000000
--- a/src/main/java/com/ljunggren/yamlUtils/YamlUtils.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.ljunggren.yamlUtils;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
-
-public class YamlUtils {
-
- public static String objectToYaml(Object object) throws JsonProcessingException {
- ObjectMapper mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER));
- return mapper.writeValueAsString(object);
- }
-
- public static T yamlToObject(String yaml, Class clazz) throws JsonMappingException, JsonProcessingException {
- return new ObjectMapper(new YAMLFactory()).readValue(yaml, clazz);
- }
-
- public static boolean isValid(String yaml) {
- try {
- new ObjectMapper(new YAMLFactory()).readTree(yaml);
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- public static boolean areEqual(String yaml1, String yaml2) throws JsonMappingException, JsonProcessingException {
- ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- return mapper.readTree(yaml1).equals(mapper.readTree(yaml2));
- }
-
-}
diff --git a/src/main/java/io/ljunggren/yamlUtils/YamlUtils.java b/src/main/java/io/ljunggren/yamlUtils/YamlUtils.java
new file mode 100644
index 0000000..98461f1
--- /dev/null
+++ b/src/main/java/io/ljunggren/yamlUtils/YamlUtils.java
@@ -0,0 +1,34 @@
+package io.ljunggren.yamlUtils;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
+
+public class YamlUtils {
+
+ public static String objectToYaml(Object object) throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER));
+ return mapper.writeValueAsString(object);
+ }
+
+ public static T yamlToObject(String yaml, Class clazz) throws JsonMappingException, JsonProcessingException {
+ return new ObjectMapper(new YAMLFactory()).readValue(yaml, clazz);
+ }
+
+ public static boolean isValid(String yaml) {
+ try {
+ new ObjectMapper(new YAMLFactory()).readTree(yaml);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public static boolean areEqual(String yaml1, String yaml2) throws JsonMappingException, JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ return mapper.readTree(yaml1).equals(mapper.readTree(yaml2));
+ }
+
+}
diff --git a/src/test/java/com/ljunggren/yamlUtils/YamlUtilsTest.java b/src/test/java/com/ljunggren/yamlUtils/YamlUtilsTest.java
deleted file mode 100644
index 0a31927..0000000
--- a/src/test/java/com/ljunggren/yamlUtils/YamlUtilsTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.ljunggren.yamlUtils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-public class YamlUtilsTest {
-
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- private static class User {
- private String name;
- private int age;
- private boolean active;
- }
-
- @Test
- public void objectToYamlTest() throws JsonProcessingException {
- User user = new User("Alex", 40, true);
- String expected = "name: \"Alex\"\n"
- + "age: 40\n"
- + "active: true\n";
- String actual = YamlUtils.objectToYaml(user);
- assertEquals(expected, actual);
- }
-
- @Test
- public void yamlToObjectTest() throws JsonMappingException, JsonProcessingException {
- User user = new User("Alex", 40, true);
- String yaml = YamlUtils.objectToYaml(user);
- User generatedUser = YamlUtils.yamlToObject(yaml, User.class);
- assertEquals(user, generatedUser);
- }
-
- @Test
- public void isValidTest() throws JsonProcessingException {
- User user = new User("Alex", 40, true);
- String yaml = YamlUtils.objectToYaml(user);
- assertTrue(YamlUtils.isValid(yaml));
- }
-
- @Test
- public void isValidFalseTest() {
- String yaml = "`name";
- assertFalse(YamlUtils.isValid(yaml));
- }
-
- @Test
- public void areEqualTest() throws JsonProcessingException {
- User user = new User("Alex", 40, true);
- String expected = "# comment\n"
- + "name: \"Alex\"\n"
- + "age: 40\n"
- + "active: true\n";
- String actual = YamlUtils.objectToYaml(user);
- assertTrue(YamlUtils.areEqual(expected, actual));
- }
-
- @Test
- public void areEqualFalseTest() throws JsonProcessingException {
- User user = new User("Alex", 40, true);
- String expected = "# comment\n"
- + "name: \"Alexander\"\n"
- + "age: 40\n"
- + "active: true\n";
- String actual = YamlUtils.objectToYaml(user);
- assertFalse(YamlUtils.areEqual(expected, actual));
- }
-
-}
diff --git a/src/test/java/io/ljunggren/yamlUtils/YamlUtilsTest.java b/src/test/java/io/ljunggren/yamlUtils/YamlUtilsTest.java
new file mode 100644
index 0000000..b2d3166
--- /dev/null
+++ b/src/test/java/io/ljunggren/yamlUtils/YamlUtilsTest.java
@@ -0,0 +1,80 @@
+package io.ljunggren.yamlUtils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+public class YamlUtilsTest {
+
+ @Data
+ @NoArgsConstructor
+ @AllArgsConstructor
+ private static class User {
+ private String name;
+ private int age;
+ private boolean active;
+ }
+
+ @Test
+ public void objectToYamlTest() throws JsonProcessingException {
+ User user = new User("Alex", 40, true);
+ String expected = "name: \"Alex\"\n"
+ + "age: 40\n"
+ + "active: true\n";
+ String actual = YamlUtils.objectToYaml(user);
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void yamlToObjectTest() throws JsonMappingException, JsonProcessingException {
+ User user = new User("Alex", 40, true);
+ String yaml = YamlUtils.objectToYaml(user);
+ User generatedUser = YamlUtils.yamlToObject(yaml, User.class);
+ assertEquals(user, generatedUser);
+ }
+
+ @Test
+ public void isValidTest() throws JsonProcessingException {
+ User user = new User("Alex", 40, true);
+ String yaml = YamlUtils.objectToYaml(user);
+ assertTrue(YamlUtils.isValid(yaml));
+ }
+
+ @Test
+ public void isValidFalseTest() {
+ String yaml = "`name";
+ assertFalse(YamlUtils.isValid(yaml));
+ }
+
+ @Test
+ public void areEqualTest() throws JsonProcessingException {
+ User user = new User("Alex", 40, true);
+ String expected = "# comment\n"
+ + "name: \"Alex\"\n"
+ + "age: 40\n"
+ + "active: true\n";
+ String actual = YamlUtils.objectToYaml(user);
+ assertTrue(YamlUtils.areEqual(expected, actual));
+ }
+
+ @Test
+ public void areEqualFalseTest() throws JsonProcessingException {
+ User user = new User("Alex", 40, true);
+ String expected = "# comment\n"
+ + "name: \"Alexander\"\n"
+ + "age: 40\n"
+ + "active: true\n";
+ String actual = YamlUtils.objectToYaml(user);
+ assertFalse(YamlUtils.areEqual(expected, actual));
+ }
+
+}