2008-11-19 02:22:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Google Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.google.gson;
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
import static com.google.common.truth.Truth.assertThat;
|
2022-10-16 21:30:49 +02:00
|
|
|
import static org.junit.Assert.fail;
|
|
|
|
|
2011-02-15 01:14:20 +01:00
|
|
|
import com.google.gson.common.MoreAsserts;
|
2022-08-18 22:10:43 +02:00
|
|
|
import java.util.AbstractMap.SimpleEntry;
|
|
|
|
import java.util.ArrayDeque;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Deque;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.Set;
|
2022-10-16 21:30:49 +02:00
|
|
|
import org.junit.Test;
|
2008-11-19 02:22:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit test for the {@link JsonObject} class.
|
|
|
|
*
|
|
|
|
* @author Joel Leitch
|
|
|
|
*/
|
2022-10-16 21:30:49 +02:00
|
|
|
public class JsonObjectTest {
|
2008-11-19 02:22:21 +01:00
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2023-01-17 16:59:10 +01:00
|
|
|
public void testAddingAndRemovingObjectProperties() {
|
2008-11-19 02:22:21 +01:00
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
String propertyName = "property";
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.has(propertyName)).isFalse();
|
|
|
|
assertThat(jsonObj.get(propertyName)).isNull();
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2008-11-19 02:22:21 +01:00
|
|
|
JsonPrimitive value = new JsonPrimitive("blah");
|
|
|
|
jsonObj.add(propertyName, value);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.get(propertyName)).isEqualTo(value);
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2008-11-19 02:22:21 +01:00
|
|
|
JsonElement removedElement = jsonObj.remove(propertyName);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(removedElement).isEqualTo(value);
|
|
|
|
assertThat(jsonObj.has(propertyName)).isFalse();
|
|
|
|
assertThat(jsonObj.get(propertyName)).isNull();
|
2022-09-09 16:32:55 +02:00
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.remove(propertyName)).isNull();
|
2008-11-19 02:22:21 +01:00
|
|
|
}
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2023-01-17 16:59:10 +01:00
|
|
|
public void testAddingNullPropertyValue() {
|
2008-11-19 02:22:21 +01:00
|
|
|
String propertyName = "property";
|
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
jsonObj.add(propertyName, null);
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.has(propertyName)).isTrue();
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2008-11-19 02:22:21 +01:00
|
|
|
JsonElement jsonElement = jsonObj.get(propertyName);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonElement).isNotNull();
|
|
|
|
assertThat(jsonElement.isJsonNull()).isTrue();
|
2008-11-19 02:22:21 +01:00
|
|
|
}
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2023-01-17 16:59:10 +01:00
|
|
|
public void testAddingNullOrEmptyPropertyName() {
|
2009-10-09 23:12:07 +02:00
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
try {
|
2011-06-03 21:02:28 +02:00
|
|
|
jsonObj.add(null, JsonNull.INSTANCE);
|
2009-10-09 23:12:07 +02:00
|
|
|
fail("Should not allow null property names.");
|
2011-03-16 08:23:44 +01:00
|
|
|
} catch (NullPointerException expected) { }
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2011-06-03 21:02:28 +02:00
|
|
|
jsonObj.add("", JsonNull.INSTANCE);
|
|
|
|
jsonObj.add(" \t", JsonNull.INSTANCE);
|
2009-10-09 23:12:07 +02:00
|
|
|
}
|
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2023-01-17 16:59:10 +01:00
|
|
|
public void testAddingBooleanProperties() {
|
2008-12-01 00:36:29 +01:00
|
|
|
String propertyName = "property";
|
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
jsonObj.addProperty(propertyName, true);
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.has(propertyName)).isTrue();
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2008-12-01 00:36:29 +01:00
|
|
|
JsonElement jsonElement = jsonObj.get(propertyName);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonElement).isNotNull();
|
|
|
|
assertThat(jsonElement.getAsBoolean()).isTrue();
|
2008-12-01 00:36:29 +01:00
|
|
|
}
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2023-01-17 16:59:10 +01:00
|
|
|
public void testAddingStringProperties() {
|
2008-12-01 00:36:29 +01:00
|
|
|
String propertyName = "property";
|
|
|
|
String value = "blah";
|
|
|
|
|
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
jsonObj.addProperty(propertyName, value);
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.has(propertyName)).isTrue();
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2008-12-01 00:36:29 +01:00
|
|
|
JsonElement jsonElement = jsonObj.get(propertyName);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonElement).isNotNull();
|
|
|
|
assertThat(jsonElement.getAsString()).isEqualTo(value);
|
2008-12-01 00:36:29 +01:00
|
|
|
}
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2023-01-17 16:59:10 +01:00
|
|
|
public void testAddingCharacterProperties() {
|
2008-12-01 00:36:29 +01:00
|
|
|
String propertyName = "property";
|
|
|
|
char value = 'a';
|
|
|
|
|
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
jsonObj.addProperty(propertyName, value);
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.has(propertyName)).isTrue();
|
2009-10-09 23:12:07 +02:00
|
|
|
|
2008-12-01 00:36:29 +01:00
|
|
|
JsonElement jsonElement = jsonObj.get(propertyName);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonElement).isNotNull();
|
|
|
|
assertThat(jsonElement.getAsString()).isEqualTo(String.valueOf(value));
|
2021-11-07 17:43:49 +01:00
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
char character = jsonElement.getAsCharacter();
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(character).isEqualTo(value);
|
2008-12-01 00:36:29 +01:00
|
|
|
}
|
2010-08-20 07:45:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* From bug report http://code.google.com/p/google-gson/issues/detail?id=182
|
|
|
|
*/
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2010-08-20 07:45:51 +02:00
|
|
|
public void testPropertyWithQuotes() {
|
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
jsonObj.add("a\"b", new JsonPrimitive("c\"d"));
|
|
|
|
String json = new Gson().toJson(jsonObj);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(json).isEqualTo("{\"a\\\"b\":\"c\\\"d\"}");
|
2010-08-20 07:45:51 +02:00
|
|
|
}
|
2010-08-28 07:02:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* From issue 227.
|
|
|
|
*/
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2010-08-28 07:02:33 +02:00
|
|
|
public void testWritePropertyWithEmptyStringName() {
|
|
|
|
JsonObject jsonObj = new JsonObject();
|
|
|
|
jsonObj.add("", new JsonPrimitive(true));
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(new Gson().toJson(jsonObj)).isEqualTo("{\"\":true}");
|
2010-08-28 07:02:33 +02:00
|
|
|
}
|
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2010-08-28 07:02:33 +02:00
|
|
|
public void testReadPropertyWithEmptyStringName() {
|
2019-04-15 23:25:40 +02:00
|
|
|
JsonObject jsonObj = JsonParser.parseString("{\"\":true}").getAsJsonObject();
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(jsonObj.get("").getAsBoolean()).isTrue();
|
2011-02-15 01:14:20 +01:00
|
|
|
}
|
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2011-02-15 01:14:20 +01:00
|
|
|
public void testEqualsOnEmptyObject() {
|
|
|
|
MoreAsserts.assertEqualsAndHashCode(new JsonObject(), new JsonObject());
|
|
|
|
}
|
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2011-02-15 01:14:20 +01:00
|
|
|
public void testEqualsNonEmptyObject() {
|
|
|
|
JsonObject a = new JsonObject();
|
|
|
|
JsonObject b = new JsonObject();
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(a).isEqualTo(a);
|
2011-04-05 00:09:51 +02:00
|
|
|
|
2011-02-15 01:14:20 +01:00
|
|
|
a.add("foo", new JsonObject());
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(a.equals(b)).isFalse();
|
|
|
|
assertThat(b.equals(a)).isFalse();
|
2011-02-15 01:14:20 +01:00
|
|
|
|
|
|
|
b.add("foo", new JsonObject());
|
|
|
|
MoreAsserts.assertEqualsAndHashCode(a, b);
|
|
|
|
|
|
|
|
a.add("bar", new JsonObject());
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(a.equals(b)).isFalse();
|
|
|
|
assertThat(b.equals(a)).isFalse();
|
2010-08-28 07:02:33 +02:00
|
|
|
|
2011-05-25 18:48:39 +02:00
|
|
|
b.add("bar", JsonNull.INSTANCE);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(a.equals(b)).isFalse();
|
|
|
|
assertThat(b.equals(a)).isFalse();
|
2010-08-28 07:02:33 +02:00
|
|
|
}
|
2012-08-21 03:19:43 +02:00
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2022-09-09 16:32:55 +02:00
|
|
|
public void testEqualsHashCodeIgnoringOrder() {
|
|
|
|
JsonObject a = new JsonObject();
|
|
|
|
JsonObject b = new JsonObject();
|
|
|
|
|
|
|
|
a.addProperty("1", true);
|
|
|
|
b.addProperty("2", false);
|
|
|
|
|
|
|
|
a.addProperty("2", false);
|
|
|
|
b.addProperty("1", true);
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(new ArrayList<>(a.keySet())).containsExactly("1", "2").inOrder();
|
|
|
|
assertThat(new ArrayList<>(b.keySet())).containsExactly("2", "1").inOrder();
|
2022-09-09 16:32:55 +02:00
|
|
|
|
|
|
|
MoreAsserts.assertEqualsAndHashCode(a, b);
|
|
|
|
}
|
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2016-06-10 06:46:32 +02:00
|
|
|
public void testSize() {
|
|
|
|
JsonObject o = new JsonObject();
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.size()).isEqualTo(0);
|
2016-06-10 06:46:32 +02:00
|
|
|
|
|
|
|
o.add("Hello", new JsonPrimitive(1));
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.size()).isEqualTo(1);
|
2016-06-10 06:46:32 +02:00
|
|
|
|
|
|
|
o.add("Hi", new JsonPrimitive(1));
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.size()).isEqualTo(2);
|
2016-06-10 06:46:32 +02:00
|
|
|
|
|
|
|
o.remove("Hello");
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.size()).isEqualTo(1);
|
2016-06-10 06:46:32 +02:00
|
|
|
}
|
|
|
|
|
2022-11-13 21:58:30 +01:00
|
|
|
@Test
|
|
|
|
public void testIsEmpty() {
|
|
|
|
JsonObject o = new JsonObject();
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.isEmpty()).isTrue();
|
2022-11-13 21:58:30 +01:00
|
|
|
|
|
|
|
o.add("Hello", new JsonPrimitive(1));
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.isEmpty()).isFalse();
|
2022-11-13 21:58:30 +01:00
|
|
|
|
|
|
|
o.remove("Hello");
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.isEmpty()).isTrue();
|
2022-11-13 21:58:30 +01:00
|
|
|
}
|
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2012-08-21 03:19:43 +02:00
|
|
|
public void testDeepCopy() {
|
|
|
|
JsonObject original = new JsonObject();
|
|
|
|
JsonArray firstEntry = new JsonArray();
|
|
|
|
original.add("key", firstEntry);
|
|
|
|
|
|
|
|
JsonObject copy = original.deepCopy();
|
|
|
|
firstEntry.add(new JsonPrimitive("z"));
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(original.get("key").getAsJsonArray()).hasSize(1);
|
|
|
|
assertThat(copy.get("key").getAsJsonArray()).hasSize(0);
|
2012-08-21 03:19:43 +02:00
|
|
|
}
|
2016-12-14 07:15:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* From issue 941
|
|
|
|
*/
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2016-12-14 07:15:49 +01:00
|
|
|
public void testKeySet() {
|
|
|
|
JsonObject a = new JsonObject();
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(a.keySet()).hasSize(0);
|
2016-12-14 07:15:49 +01:00
|
|
|
|
|
|
|
a.add("foo", new JsonArray());
|
|
|
|
a.add("bar", new JsonObject());
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(a.size()).isEqualTo(2);
|
|
|
|
assertThat(a.keySet()).hasSize(2);
|
|
|
|
assertThat(a.keySet().contains("foo")).isTrue();
|
|
|
|
assertThat(a.keySet().contains("bar")).isTrue();
|
2022-08-18 22:10:43 +02:00
|
|
|
|
|
|
|
a.addProperty("1", true);
|
|
|
|
a.addProperty("2", false);
|
|
|
|
|
|
|
|
// Insertion order should be preserved by keySet()
|
|
|
|
Deque<String> expectedKeys = new ArrayDeque<>(Arrays.asList("foo", "bar", "1", "2"));
|
|
|
|
// Note: Must wrap in ArrayList because Deque implementations do not implement `equals`
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(new ArrayList<>(a.keySet())).isEqualTo(new ArrayList<>(expectedKeys));
|
2022-08-18 22:10:43 +02:00
|
|
|
Iterator<String> iterator = a.keySet().iterator();
|
|
|
|
|
|
|
|
// Remove keys one by one
|
|
|
|
for (int i = a.size(); i >= 1; i--) {
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(iterator.hasNext()).isTrue();
|
|
|
|
assertThat(iterator.next()).isEqualTo(expectedKeys.getFirst());
|
2022-08-18 22:10:43 +02:00
|
|
|
iterator.remove();
|
|
|
|
expectedKeys.removeFirst();
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(a.size()).isEqualTo(i - 1);
|
|
|
|
assertThat(new ArrayList<>(a.keySet())).isEqualTo(new ArrayList<>(expectedKeys));
|
2022-08-18 22:10:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-16 21:30:49 +02:00
|
|
|
@Test
|
2022-08-18 22:10:43 +02:00
|
|
|
public void testEntrySet() {
|
|
|
|
JsonObject o = new JsonObject();
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.entrySet()).hasSize(0);
|
2022-08-18 22:10:43 +02:00
|
|
|
|
|
|
|
o.addProperty("b", true);
|
|
|
|
Set<?> expectedEntries = Collections.singleton(new SimpleEntry<>("b", new JsonPrimitive(true)));
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.entrySet()).isEqualTo(expectedEntries);
|
|
|
|
assertThat(o.entrySet()).hasSize(1);
|
2022-08-18 22:10:43 +02:00
|
|
|
|
|
|
|
o.addProperty("a", false);
|
|
|
|
// Insertion order should be preserved by entrySet()
|
|
|
|
List<?> expectedEntriesList = Arrays.asList(
|
|
|
|
new SimpleEntry<>("b", new JsonPrimitive(true)),
|
|
|
|
new SimpleEntry<>("a", new JsonPrimitive(false))
|
|
|
|
);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(new ArrayList<>(o.entrySet())).isEqualTo(expectedEntriesList);
|
2022-08-18 22:10:43 +02:00
|
|
|
|
|
|
|
Iterator<Entry<String, JsonElement>> iterator = o.entrySet().iterator();
|
|
|
|
// Test behavior of Entry.setValue
|
|
|
|
for (int i = 0; i < o.size(); i++) {
|
|
|
|
Entry<String, JsonElement> entry = iterator.next();
|
|
|
|
entry.setValue(new JsonPrimitive(i));
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(entry.getValue()).isEqualTo(new JsonPrimitive(i));
|
2022-08-18 22:10:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
expectedEntriesList = Arrays.asList(
|
|
|
|
new SimpleEntry<>("b", new JsonPrimitive(0)),
|
|
|
|
new SimpleEntry<>("a", new JsonPrimitive(1))
|
|
|
|
);
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(new ArrayList<>(o.entrySet())).isEqualTo(expectedEntriesList);
|
2022-08-18 22:10:43 +02:00
|
|
|
|
|
|
|
Entry<String, JsonElement> entry = o.entrySet().iterator().next();
|
|
|
|
try {
|
|
|
|
// null value is not permitted, only JsonNull is supported
|
|
|
|
// This intentionally deviates from the behavior of the other JsonObject methods which
|
|
|
|
// implicitly convert null -> JsonNull, to match more closely the contract of Map.Entry
|
|
|
|
entry.setValue(null);
|
|
|
|
fail();
|
|
|
|
} catch (NullPointerException e) {
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(e).hasMessageThat().isEqualTo("value == null");
|
2022-08-18 22:10:43 +02:00
|
|
|
}
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(entry.getValue()).isNotNull();
|
2022-08-18 22:10:43 +02:00
|
|
|
|
|
|
|
o.addProperty("key1", 1);
|
|
|
|
o.addProperty("key2", 2);
|
|
|
|
|
|
|
|
Deque<?> expectedEntriesQueue = new ArrayDeque<>(Arrays.asList(
|
|
|
|
new SimpleEntry<>("b", new JsonPrimitive(0)),
|
|
|
|
new SimpleEntry<>("a", new JsonPrimitive(1)),
|
|
|
|
new SimpleEntry<>("key1", new JsonPrimitive(1)),
|
|
|
|
new SimpleEntry<>("key2", new JsonPrimitive(2))
|
|
|
|
));
|
|
|
|
// Note: Must wrap in ArrayList because Deque implementations do not implement `equals`
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(new ArrayList<>(o.entrySet())).isEqualTo(new ArrayList<>(expectedEntriesQueue));
|
2022-08-18 22:10:43 +02:00
|
|
|
iterator = o.entrySet().iterator();
|
|
|
|
|
|
|
|
// Remove entries one by one
|
|
|
|
for (int i = o.size(); i >= 1; i--) {
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(iterator.hasNext()).isTrue();
|
|
|
|
assertThat(iterator.next()).isEqualTo(expectedEntriesQueue.getFirst());
|
2022-08-18 22:10:43 +02:00
|
|
|
iterator.remove();
|
|
|
|
expectedEntriesQueue.removeFirst();
|
|
|
|
|
2023-01-17 16:59:10 +01:00
|
|
|
assertThat(o.size()).isEqualTo(i - 1);
|
|
|
|
assertThat(new ArrayList<>(o.entrySet())).isEqualTo(new ArrayList<>(expectedEntriesQueue));
|
2022-08-18 22:10:43 +02:00
|
|
|
}
|
2016-12-14 07:15:49 +01:00
|
|
|
}
|
2008-11-19 02:22:21 +01:00
|
|
|
}
|