Add miscellaneous test cases

dev
Exlll 2 years ago
parent 268ce78163
commit 0eb73815be

@ -80,7 +80,7 @@ public final class Example {
var configFile = Paths.get("/tmp/config.yml");
var config = new UserConfiguration();
// Save a new instance to the configuration file
// Save an instance to the configuration file
YamlConfigurations.save(configFile, UserConfiguration.class, config);
// Load a new instance from the configuration file
@ -88,7 +88,7 @@ public final class Example {
System.out.println(config.admin.username);
System.out.println(config.blockedUsers);
// Modify and save the configuration file
// Modify the configuration and save it again
config.blockedUsers.add(new User("user3", "pass3"));
YamlConfigurations.save(configFile, UserConfiguration.class, config);
}
@ -446,8 +446,8 @@ missing. That can happen, for example, when somebody deleted that value from the
when you add configuration elements to your configuration type, or when the `NameFormatter` that
was used to create that file is replaced.
In such cases, fields of configuration types keep the default value you assigned to them and record
components are initialized with the default value of their corresponding type.
In such cases, fields of configuration classes keep the default value you assigned to them and
record components are initialized with the default value of their corresponding type.
#### Null values
@ -792,7 +792,7 @@ public final class RecursiveTypDefinitions {
</details>
## Project structure
## Project and repository structure
This project contains three classes of modules:
@ -811,6 +811,13 @@ This project contains three classes of modules:
object which adds support for the serialization of Bukkit classes like `ItemStack` as
described [here](#support-for-bukkit-classes-like-itemstack).
The GitHub repository of this project uses two branches:
* The `master` branch contains the functionality of the latest release version.
* The `dev` branch contains the newest, possibly unstable features and refactorings.
If you plan to contribute to this project, please base your commits on the `dev` branch.
## Import
To use this library, import it into your project with Maven or Gradle. Examples of how to do that
@ -876,7 +883,9 @@ dependencies { implementation("com.github.Exlll.ConfigLib:configlib-yaml:v4.1.0"
</details>
<details>
<summary>Import via GitHub</summary>
<summary>
Import via GitHub
</summary>
Importing via GitHub requires authentication. Check
this [issue](https://github.com/Exlll/ConfigLib/issues/12) if you have any trouble with that.

@ -75,7 +75,8 @@ public @interface SerializeWith {
*
* @return the type of serializer to use
*/
Class<? extends Serializer<?, ?>> serializer();
@SuppressWarnings("rawtypes")
Class<? extends Serializer> serializer();
/**
* Returns the nesting level at which to apply the serializer.

@ -254,4 +254,25 @@ class ExampleConfigurationTests {
ExampleRecord2 deserialize2 = serializer.deserialize(EXAMPLE_RECORD2_2);
assertExampleRecord2Equal(ExampleInitializer.EXAMPLE_RECORD2_2, deserialize2);
}
@Test
void serializeExampleConfigurationCustom() {
ConfigurationSerializer<ExampleConfigurationCustom> serializer =
new ConfigurationSerializer<>(ExampleConfigurationCustom.class, PROPERTIES_ALLOW_NULL);
ExampleConfigurationCustom config = new ExampleConfigurationCustom();
Map<?, ?> serialized = serializer.serialize(config);
assertEquals(EXAMPLE_CONFIGURATION_CUSTOM, serialized);
}
@Test
void deserializeExampleConfigurationCustom() {
ConfigurationSerializer<ExampleConfigurationCustom> serializer =
new ConfigurationSerializer<>(ExampleConfigurationCustom.class, PROPERTIES_ALLOW_NULL);
assertExampleConfigurationsCustomEqual(
serializer.deserialize(EXAMPLE_CONFIGURATION_CUSTOM),
new ExampleConfigurationCustom()
);
}
}

@ -539,7 +539,7 @@ class SerializerSelectorTest {
}
@Test
void selectCustomSerializerfieldAsElement() {
void selectCustomSerializerForField() {
var serializer = SELECTOR.select(fieldAsElement(Z.class, "string"));
assertThat(serializer, instanceOf(IdentitySerializer.class));
}
@ -690,6 +690,63 @@ class SerializerSelectorTest {
@Override
public String deserialize(String element) {return null;}
}
@Test
void selectCustomSerializerWithOnUnsupportedTypes() {
record Box<T>(T element) {}
@SuppressWarnings("rawtypes")
final class UnsupportedTypes<T> {
@SerializeWith(serializer = IdentitySerializer.class)
Map<Point, String> mapPointString1;
@SerializeWith(serializer = IdentitySerializer.class)
Map<List<String>, String> mapListStringString;
@SerializeWith(serializer = IdentitySerializer.class)
Box<String> boxString;
@SerializeWith(serializer = IdentitySerializer.class)
List<? extends String> listWildcardExtendsString;
@SerializeWith(serializer = IdentitySerializer.class)
List<?> listWildcard;
@SerializeWith(serializer = IdentitySerializer.class)
List<?>[] arrayListWildcard;
@SerializeWith(serializer = IdentitySerializer.class)
T typeVariable;
@SerializeWith(serializer = IdentitySerializer.class)
List listRaw;
@SerializeWith(serializer = IdentitySerializer.class)
List[] arrayListRaw;
@SerializeWith(serializer = IdentitySerializer.class)
List<String>[] arrayListString;
@SerializeWith(serializer = IdentitySerializer.class)
Set<Integer>[] arraySetInteger;
@SerializeWith(serializer = IdentitySerializer.class)
Map<Byte, Byte>[] arrayMapByteByte;
}
final class Config {
@SerializeWith(serializer = IdentitySerializer.class)
UnsupportedTypes<Point> unsupportedTypes;
}
assertInstanceOfIdentitySerializer(Config.class, "unsupportedTypes");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "mapPointString1");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "mapListStringString");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "boxString");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "listWildcardExtendsString");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "listWildcard");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "arrayListWildcard");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "typeVariable");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "listRaw");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "arrayListRaw");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "arrayListString");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "arraySetInteger");
assertInstanceOfIdentitySerializer(UnsupportedTypes.class, "arrayMapByteByte");
}
static void assertInstanceOfIdentitySerializer(Class<?> type, String fieldName) {
var serializer = SELECTOR.select(fieldAsElement(type, fieldName));
assertThat(serializer, instanceOf(IdentitySerializer.class));
}
}
static final class SerializeWithOnTypesTest {

@ -131,16 +131,38 @@ public final class TestUtils {
implements Serializer<Object, Object> {
@Override
public Object serialize(Object element) {
return element;
}
@Override
public Object deserialize(Object element) {
return element;
}
public Object serialize(Object element) {
return element;
}
@Override
public Object deserialize(Object element) {
return element;
}
}
public record ThrowingSerializer(SerializerContext context)
implements Serializer<Object, Object> {
public ThrowingSerializer {
throw new UnsupportedOperationException(context.toString());
}
@Override
public Object serialize(Object element) {
throw new UnsupportedOperationException(element.toString());
}
@Override
public Object deserialize(Object element) {
throw new UnsupportedOperationException(element.toString());
}
}
@SafeVarargs
public static <E> List<E> asList(E... elements) {
return new ArrayList<>(Arrays.asList(elements));
}
@SafeVarargs
public static <E> Set<E> asSet(E... elements) {

@ -0,0 +1,341 @@
package de.exlll.configlib.configurations;
import de.exlll.configlib.*;
import de.exlll.configlib.TestUtils.ThrowingSerializer;
import java.util.*;
import static de.exlll.configlib.TestUtils.*;
@SuppressWarnings("FieldMayBeFinal")
@Configuration
public final class ExampleConfigurationCustom {
/* ******************** @SerializeWith ON CONFIGURATION ELEMENTS ******************** */
@SerializeWith(serializer = ThrowingSerializer.class, nesting = -1)
private List<List<String>> listListString0 = asList(asList("1"));
@SerializeWith(serializer = DoublingListSerializer.class)
private List<List<String>> listListString1 = listListString0;
@SerializeWith(serializer = DoublingListSerializer.class, nesting = 1)
private List<List<String>> listListString2 = listListString0;
@SerializeWith(serializer = DoublingStringSerializer.class, nesting = 2)
private List<List<String>> listListString3 = listListString0;
@SerializeWith(serializer = ThrowingSerializer.class, nesting = 3)
private List<List<String>> listListString4 = listListString0;
@SerializeWith(serializer = ThrowingSerializer.class, nesting = -1)
private Map<Integer, Map<Integer, String>> mapIntegerMapIntegerString0 =
asMap(1, asMap(2, "3"));
@SerializeWith(serializer = DoublingKeySerializer.class)
private Map<Integer, Map<Integer, String>> mapIntegerMapIntegerString1 =
mapIntegerMapIntegerString0;
@SerializeWith(serializer = DoublingKeySerializer.class, nesting = 1)
private Map<Integer, Map<Integer, String>> mapIntegerMapIntegerString2 =
mapIntegerMapIntegerString0;
@SerializeWith(serializer = DoublingStringSerializer.class, nesting = 2)
private Map<Integer, Map<Integer, String>> mapIntegerMapIntegerString3 =
mapIntegerMapIntegerString0;
@SerializeWith(serializer = ThrowingSerializer.class, nesting = 3)
private Map<Integer, Map<Integer, String>> mapIntegerMapIntegerString4 =
mapIntegerMapIntegerString0;
/* ******************** POLYMORPHIC TYPES ******************** */
private Poly1 poly1_1 = new Poly1Impl1(10);
private Poly2 poly2_1 = new Poly2Impl1(10);
private Poly3 poly3_1 = new Poly3Impl1();
private Poly4 poly4 = new Poly4();
private Poly4 poly4_1 = new Poly4Impl1();
private Poly5 poly5 = new Poly5();
private List<Set<Poly1>> listSetPoly1 = asList(asSet(poly1_1), asSet(poly1_1, new Poly1Impl2("s")));
private List<Set<Poly2>> listSetPoly2 = asList(asSet(poly2_1), asSet(poly2_1, new Poly2Impl2("s")));
private List<Set<Poly3>> listSetPoly3 = asList(asSet(poly3_1), asSet(poly3_1, new Poly3Impl2()));
private List<Set<Poly4>> listSetPoly4 = asList(asSet(poly4), asSet(poly4_1, new Poly4Impl2()));
private List<Set<Poly5>> listSetPoly5 = asList(asSet(poly5), asSet(poly5));
/* ******************** POLYMORPHIC TYPE DEFINITIONS ******************** */
@Polymorphic
interface Poly1 {}
record Poly1Impl1(int i) implements Poly1 {}
record Poly1Impl2(String s) implements Poly1 {}
@Polymorphic(property = "==")
@PolymorphicTypes({
@PolymorphicTypes.Type(type = Poly2Impl1.class, alias = "POLY2_IMPL1"),
@PolymorphicTypes.Type(type = Poly2Impl2.class, alias = "POLY2_IMPL2")
})
interface Poly2 {}
record Poly2Impl1(int i) implements Poly2 {}
record Poly2Impl2(String s) implements Poly2 {}
@Polymorphic
@Configuration
static abstract class Poly3 {
double d = 20;
}
static final class Poly3Impl1 extends Poly3 {
int i = 10;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Poly3Impl1 that = (Poly3Impl1) o;
return i == that.i;
}
@Override
public int hashCode() {
return i;
}
}
static final class Poly3Impl2 extends Poly3 {
String s = "s";
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Poly3Impl2 that = (Poly3Impl2) o;
return Objects.equals(s, that.s);
}
@Override
public int hashCode() {
return s != null ? s.hashCode() : 0;
}
}
@Polymorphic
@Configuration
static class Poly4 {
double d = 20;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Poly4 poly4 = (Poly4) o;
return Double.compare(poly4.d, d) == 0;
}
@Override
public int hashCode() {
long temp = Double.doubleToLongBits(d);
return (int) (temp ^ (temp >>> 32));
}
}
static final class Poly4Impl1 extends Poly4 {
int i = 10;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Poly4Impl1 that = (Poly4Impl1) o;
return i == that.i;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + i;
return result;
}
}
static final class Poly4Impl2 extends Poly4 {
String s = "s";
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Poly4Impl2 that = (Poly4Impl2) o;
return Objects.equals(s, that.s);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (s != null ? s.hashCode() : 0);
return result;
}
}
@Polymorphic
@Configuration
static final class Poly5 {
double d = 20;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Poly5 poly5 = (Poly5) o;
return Double.compare(poly5.d, d) == 0;
}
@Override
public int hashCode() {
long temp = Double.doubleToLongBits(d);
return (int) (temp ^ (temp >>> 32));
}
}
/* ******************** CUSTOM SERIALIZERS ******************** */
public static final class DoublingKeySerializer<V>
implements Serializer<Map<Integer, V>, Map<Integer, V>> {
public DoublingKeySerializer(SerializerContext context) {
if (context.element().type() != Map.class) {
throw new RuntimeException(context.element().type().getName());
}
}
@Override
public Map<Integer, V> serialize(Map<Integer, V> element) {
Map<Integer, V> result = new LinkedHashMap<>();
element.forEach((integer, v) -> result.put(integer * 2, v));
return result;
}
@Override
public Map<Integer, V> deserialize(Map<Integer, V> element) {
Map<Integer, V> result = new LinkedHashMap<>();
element.forEach((integer, v) -> result.put(integer / 2, v));
return result;
}
}
public static final class DoublingListSerializer<T>
implements Serializer<List<T>, List<T>> {
public DoublingListSerializer(SerializerContext context) {
if (context.element().type() != List.class) {
throw new RuntimeException(context.element().type().getName());
}
}
@Override
public List<T> serialize(List<T> element) {
List<T> result = new ArrayList<>(element);
result.addAll(element);
return result;
}
@Override
public List<T> deserialize(List<T> element) {
return element.subList(0, element.size() / 2);
}
}
public static final class DoublingStringSerializer
implements Serializer<String, String> {
@Override
public String serialize(String element) {
return element + element;
}
@Override
public String deserialize(String element) {
return element.substring(0, element.length() / 2);
}
}
public List<List<String>> getListListString0() {
return listListString0;
}
public List<List<String>> getListListString1() {
return listListString1;
}
public List<List<String>> getListListString2() {
return listListString2;
}
public List<List<String>> getListListString3() {
return listListString3;
}
public List<List<String>> getListListString4() {
return listListString4;
}
public Map<Integer, Map<Integer, String>> getMapIntegerMapIntegerString0() {
return mapIntegerMapIntegerString0;
}
public Map<Integer, Map<Integer, String>> getMapIntegerMapIntegerString1() {
return mapIntegerMapIntegerString1;
}
public Map<Integer, Map<Integer, String>> getMapIntegerMapIntegerString2() {
return mapIntegerMapIntegerString2;
}
public Map<Integer, Map<Integer, String>> getMapIntegerMapIntegerString3() {
return mapIntegerMapIntegerString3;
}
public Map<Integer, Map<Integer, String>> getMapIntegerMapIntegerString4() {
return mapIntegerMapIntegerString4;
}
public Poly1 getPoly1_1() {
return poly1_1;
}
public Poly2 getPoly2_1() {
return poly2_1;
}
public Poly3 getPoly3_1() {
return poly3_1;
}
public Poly4 getPoly4() {
return poly4;
}
public Poly4 getPoly4_1() {
return poly4_1;
}
public Poly5 getPoly5() {
return poly5;
}
public List<Set<Poly1>> getListSetPoly1() {
return listSetPoly1;
}
public List<Set<Poly2>> getListSetPoly2() {
return listSetPoly2;
}
public List<Set<Poly3>> getListSetPoly3() {
return listSetPoly3;
}
public List<Set<Poly4>> getListSetPoly4() {
return listSetPoly4;
}
public List<Set<Poly5>> getListSetPoly5() {
return listSetPoly5;
}
}

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import static de.exlll.configlib.TestUtils.*;
import static java.util.Arrays.asList;
public final class ExampleConfigurationsSerialized {
public static final Map<String, ?> EXAMPLE_CONFIGURATION_B1_1 = entriesAsMap(
@ -499,4 +498,73 @@ public final class ExampleConfigurationsSerialized {
entry("mapNullEnmKey", entriesAsMap(entry("A", "2"))),
entry("mapNullBigIntegerValue", entriesAsMap(entry("B", "1")))
);
private static final Map<String, ?> POLY1_1 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly1Impl1",
"i", 10L
);
private static final Map<String, ?> POLY1_2 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly1Impl2",
"s", "s"
);
private static final Map<String, ?> POLY2_1 = asMap(
"==", "POLY2_IMPL1",
"i", 10L
);
private static final Map<String, ?> POLY2_2 = asMap(
"==", "POLY2_IMPL2",
"s", "s"
);
private static final Map<String, ?> POLY3_1 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly3Impl1",
"d", 20d,
"i", 10L
);
private static final Map<String, ?> POLY3_2 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly3Impl2",
"d", 20d,
"s", "s"
);
private static final Map<String, ?> POLY4 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly4",
"d", 20d
);
private static final Map<String, ?> POLY4_1 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly4Impl1",
"d", 20d,
"i", 10L
);
private static final Map<String, ?> POLY4_2 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly4Impl2",
"d", 20d,
"s", "s"
);
private static final Map<String, ?> POLY5 = asMap(
"type", "de.exlll.configlib.configurations.ExampleConfigurationCustom$Poly5",
"d", 20d
);
public static final Map<String, ?> EXAMPLE_CONFIGURATION_CUSTOM = entriesAsMap(
entry("listListString0", asList(asList("1"))),
entry("listListString1", asList(asList("1"), asList("1"))),
entry("listListString2", asList(asList("1", "1"))),
entry("listListString3", asList(asList("11"))),
entry("listListString4", asList(asList("1"))),
entry("mapIntegerMapIntegerString0", asMap(1L, asMap(2L, "3"))),
entry("mapIntegerMapIntegerString1", asMap(2, asMap(2, "3"))),
entry("mapIntegerMapIntegerString2", asMap(1L, asMap(4, "3"))),
entry("mapIntegerMapIntegerString3", asMap(1L, asMap(2L, "33"))),
entry("mapIntegerMapIntegerString4", asMap(1L, asMap(2L, "3"))),
entry("poly1_1", POLY1_1),
entry("poly2_1", POLY2_1),
entry("poly3_1", POLY3_1),
entry("poly4", POLY4),
entry("poly4_1", POLY4_1),
entry("poly5", POLY5),
entry("listSetPoly1", asList(asList(POLY1_1), asList(POLY1_1, POLY1_2))),
entry("listSetPoly2", asList(asList(POLY2_1), asList(POLY2_1, POLY2_2))),
entry("listSetPoly3", asList(asList(POLY3_1), asList(POLY3_1, POLY3_2))),
entry("listSetPoly4", asList(asList(POLY4), asList(POLY4_1, POLY4_2))),
entry("listSetPoly5", asList(asList(POLY5), asList(POLY5)))
);
}

@ -489,6 +489,36 @@ public final class ExampleEqualityAsserter {
assertEquals(b2_2, b2_1);
}
public static void assertExampleConfigurationsCustomEqual(
ExampleConfigurationCustom c1,
ExampleConfigurationCustom c2
) {
assertThat(c1.getListListString0(), is(c2.getListListString0()));
assertThat(c1.getListListString1(), is(c2.getListListString1()));
assertThat(c1.getListListString2(), is(c2.getListListString2()));
assertThat(c1.getListListString3(), is(c2.getListListString3()));
assertThat(c1.getListListString4(), is(c2.getListListString4()));
assertThat(c1.getMapIntegerMapIntegerString0(), is(c2.getMapIntegerMapIntegerString0()));
assertThat(c1.getMapIntegerMapIntegerString1(), is(c2.getMapIntegerMapIntegerString1()));
assertThat(c1.getMapIntegerMapIntegerString2(), is(c2.getMapIntegerMapIntegerString2()));
assertThat(c1.getMapIntegerMapIntegerString3(), is(c2.getMapIntegerMapIntegerString3()));
assertThat(c1.getMapIntegerMapIntegerString4(), is(c2.getMapIntegerMapIntegerString4()));
assertThat(c1.getPoly1_1(), is(c2.getPoly1_1()));
assertThat(c1.getPoly2_1(), is(c2.getPoly2_1()));
assertThat(c1.getPoly3_1(), is(c2.getPoly3_1()));
assertThat(c1.getPoly4(), is(c2.getPoly4()));
assertThat(c1.getPoly4_1(), is(c2.getPoly4_1()));
assertThat(c1.getPoly5(), is(c2.getPoly5()));
assertThat(c1.getListSetPoly1(), is(c2.getListSetPoly1()));
assertThat(c1.getListSetPoly2(), is(c2.getListSetPoly2()));
assertThat(c1.getListSetPoly3(), is(c2.getListSetPoly3()));
assertThat(c1.getListSetPoly4(), is(c2.getListSetPoly4()));
assertThat(c1.getListSetPoly5(), is(c2.getListSetPoly5()));
}
public static <T, C extends Collection<T[]>> void assertDeepEquals(
C collection1,
C collection2,

@ -2,6 +2,7 @@ package de.exlll.configlib;
import com.google.common.jimfs.Jimfs;
import de.exlll.configlib.configurations.ExampleConfigurationA2;
import de.exlll.configlib.configurations.ExampleConfigurationCustom;
import de.exlll.configlib.configurations.ExampleConfigurationNulls;
import de.exlll.configlib.configurations.ExampleInitializer;
import org.junit.jupiter.api.AfterEach;
@ -14,21 +15,9 @@ import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import static de.exlll.configlib.configurations.ExampleEqualityAsserter.assertExampleConfigurationsA2Equal;
import static de.exlll.configlib.configurations.ExampleEqualityAsserter.assertExampleConfigurationsNullsEqual;
import static de.exlll.configlib.configurations.ExampleEqualityAsserter.*;
final class ExampleConfigurationYamlTests {
private static final ConfigurationProperties PROPERTIES_ALLOW_NULL = ConfigurationProperties.newBuilder()
.addSerializer(Point.class, TestUtils.POINT_SERIALIZER)
.outputNulls(true)
.inputNulls(true)
.build();
private static final ConfigurationProperties PROPERTIES_DENY_NULL = ConfigurationProperties.newBuilder()
.addSerializer(Point.class, TestUtils.POINT_SERIALIZER)
.outputNulls(false)
.inputNulls(false)
.build();
private final FileSystem fs = Jimfs.newFileSystem();
private final Path yamlFile = fs.getPath("/tmp/config.yml");
@ -81,4 +70,14 @@ final class ExampleConfigurationYamlTests {
ExampleConfigurationNulls cfg2 = store.load(yamlFile);
assertExampleConfigurationsNullsEqual(cfg1, cfg2);
}
@Test
void yamlStoreSavesAndLoadsExampleConfigurationCustom() {
var properties = YamlConfigurationProperties.newBuilder().build();
var store = new YamlConfigurationStore<>(ExampleConfigurationCustom.class, properties);
ExampleConfigurationCustom config1 = new ExampleConfigurationCustom();
store.save(config1, yamlFile);
ExampleConfigurationCustom config2 = store.load(yamlFile);
assertExampleConfigurationsCustomEqual(config1, config2);
}
}

Loading…
Cancel
Save