From: David ‘Bombe’ Roden Date: Thu, 24 Oct 2013 05:01:26 +0000 (+0200) Subject: Don’t throw exception when removing a field that is not in the profile. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ffbea903358cf376a369987529e07d607647c41c;p=Sone.git Don’t throw exception when removing a field that is not in the profile. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Profile.java b/src/main/java/net/pterodactylus/sone/data/Profile.java index d091b89..8c1e805 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -258,15 +258,8 @@ public class Profile implements Fingerprintable { fields.add(min(fieldIndex + 1, fields.size()), field); } - /** - * Removes the given field. - * - * @param field - * The field to remove - */ public void removeField(Field field) { checkNotNull(field, "field must not be null"); - checkArgument(hasField(field), "field must belong to this profile"); fields.remove(field); } diff --git a/src/test/java/net/pterodactylus/sone/data/ProfileTest.java b/src/test/java/net/pterodactylus/sone/data/ProfileTest.java index 33d7fff..ab68bc9 100644 --- a/src/test/java/net/pterodactylus/sone/data/ProfileTest.java +++ b/src/test/java/net/pterodactylus/sone/data/ProfileTest.java @@ -119,6 +119,13 @@ public class ProfileTest { } @Test + public void testDeletingANonExistingField() { + Field testField = profile.addField("TestField"); + profile.removeField(testField); + profile.removeField(testField); + } + + @Test public void testGettingFieldList() { Field firstField = profile.addField("First"); Field secondField = profile.addField("Second");