From b2e3ba7456f47f01552c8e1300e295c48d8fe9a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 15 Mar 2015 11:34:14 +0100 Subject: [PATCH] Add new fields with an initial value of an empty string --- .../java/net/pterodactylus/sone/data/Profile.java | 2 +- .../net/pterodactylus/sone/data/ProfileTest.java | 26 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/test/java/net/pterodactylus/sone/data/ProfileTest.java diff --git a/src/main/java/net/pterodactylus/sone/data/Profile.java b/src/main/java/net/pterodactylus/sone/data/Profile.java index 1f80248..9c7da48 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -330,7 +330,7 @@ public class Profile implements Fingerprintable { throw new DuplicateField(); } @SuppressWarnings("synthetic-access") - Field field = new Field().setName(fieldName); + Field field = new Field().setName(fieldName).setValue(""); fields.add(field); return field; } diff --git a/src/test/java/net/pterodactylus/sone/data/ProfileTest.java b/src/test/java/net/pterodactylus/sone/data/ProfileTest.java new file mode 100644 index 0000000..b06e2f4 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/data/ProfileTest.java @@ -0,0 +1,26 @@ +package net.pterodactylus.sone.data; + +import net.pterodactylus.sone.data.Profile.Field; + +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.Test; +import org.mockito.Mockito; + +/** + * Unit test for {@link Profile}. + * + * @author David ‘Bombe’ Roden + */ +public class ProfileTest { + + private final Sone sone = Mockito.mock(Sone.class); + private final Profile profile = new Profile(sone); + + @Test + public void newFieldsAreInitializedWithAnEmptyString() { + Field newField = profile.addField("testField"); + MatcherAssert.assertThat(newField.getValue(), Matchers.is("")); + } + +} -- 2.7.4