Skip to content

Commit

Permalink
yegor256#814 implemented tests for ListEnvelope
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyk committed May 9, 2018
1 parent e28766b commit 6a8eda3
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions src/test/java/org/cactoos/list/ListEnvelopeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2017-2018 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.list;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import org.junit.Ignore;
import org.junit.Test;

/**
* Test case for {@link ListEnvelope}.
*
* @author Krzysztof Krason (Krzysztof.Krason@gmail.com)
* @version $Id$
* @since 0.31
* @todo #814:30min Implement immutable ListIterator and Iterator that should
* be returned from ListEnvelope when calling `listIterator` and `iterator`
* methods. After those are implemented remove `@Ignore` from the tests below
* - all of them should pass after the change.
* @checkstyle JavadocMethodCheck (500 lines)
*/
public final class ListEnvelopeTest {

@Ignore
@Test(expected = UnsupportedOperationException.class)
public void returnsListIteratorWithUnsupportedRemove() {
final ListEnvelope<String> list = new ListEnvelope<String>(
() -> {
final List<String> inner = new LinkedList<>();
inner.add("one");
return inner;
}
) { };
final Iterator<String> iterator = list.listIterator();
iterator.next();
iterator.remove();
}

@Ignore
@Test(expected = UnsupportedOperationException.class)
public void returnsIteratorWithUnsupportedRemove() {
final ListEnvelope<String> list = new ListEnvelope<String>(
() -> {
final List<String> inner = new LinkedList<>();
inner.add("eleven");
return inner;
}
) { };
final Iterator<String> iterator = list.iterator();
iterator.next();
iterator.remove();
}

@Ignore
@Test(expected = UnsupportedOperationException.class)
public void returnsListIteratorWithUnsupportedSet() {
final ListEnvelope<String> list = new ListEnvelope<String>(
() -> {
final List<String> inner = new LinkedList<>();
inner.add("three");
return inner;
}
) { };
final ListIterator<String> iterator = list.listIterator();
iterator.next();
iterator.set("zero");
}

@Ignore
@Test(expected = UnsupportedOperationException.class)
public void returnsListIteratorWithUnsupportedAdd() {
final ListEnvelope<String> list = new ListEnvelope<String>(
() -> {
final List<String> inner = new LinkedList<>();
inner.add("ten");
return inner;
}
) { };
final ListIterator<String> iterator = list.listIterator();
iterator.next();
iterator.add("twenty");
}
}

0 comments on commit 6a8eda3

Please sign in to comment.