Don’t throw exception when removing a field that is not in the profile.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 24 Oct 2013 05:01:26 +0000 (07:01 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:34 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/data/Profile.java
src/test/java/net/pterodactylus/sone/data/ProfileTest.java

index d091b89..8c1e805 100644 (file)
@@ -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);
        }
 
index 33d7fff..ab68bc9 100644 (file)
@@ -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");