reschke commented on code in PR #132: URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/132#discussion_r1922363709
########## src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntryIteratorTest.java: ########## @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.sling.resourceresolver.impl.mapping; + +import org.junit.Test; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; + +public class MapEntryIteratorTest { + + private final MapEntries.MapEntryIterator empty = + new MapEntries.MapEntryIterator(null, List.of(), key -> Collections.emptyList(), true); + + private final MapEntry xyz = + new MapEntry("/xyz", -1, false, -1, "/foo", "/bar"); + + private final MapEntry global = + new MapEntry("/foo/global/long", -1, false, -1, "bla"); + + private final Map<String, List<MapEntry>> xyzMap = + Map.of("/xyz", List.of(xyz)); + + @Test + public void testExhausted() { + assertFalse(empty.hasNext()); + assertThrows(NoSuchElementException.class, + empty::next); + } + + @Test + public void testRemove() { + assertFalse(empty.hasNext()); + assertThrows(UnsupportedOperationException.class, Review Comment: because Sonar wanted me to :-) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
