Skip to content

Commit

Permalink
Added the wrapper for static methods of java.util.List (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
Damtev authored Jul 4, 2022
1 parent a805f31 commit 1c01193
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.utbot.engine.overrides.collections;

import org.utbot.api.annotation.UtClassMock;

import java.util.Collection;

@UtClassMock(target = java.util.List.class, internalUsage = true)
public interface List<E> extends java.util.List<E> {
static <E> java.util.List<E> of() {
return new UtArrayList<>();
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1) {
return new UtArrayList<>((E[]) new Object[]{e1});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2) {
return new UtArrayList<>((E[]) new Object[]{e1, e2});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7, e8});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7, e8, e9});
}

@SuppressWarnings("unchecked")
static <E> java.util.List<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
return new UtArrayList<>((E[]) new Object[]{e1, e2, e3, e4, e5, e6, e7, e8, e9, e10});
}

@SafeVarargs
@SuppressWarnings("varargs")
static <E> java.util.List<E> of(E... elements) {
return new UtArrayList<>(elements);
}

static <E> java.util.List<E> copyOf(Collection<? extends E> collection) {
return new UtArrayList<>(collection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public UtArrayList(Collection<? extends E> c) {
addAll(c);
}

public UtArrayList(E[] data) {
visit(this);
int length = data.length;
elementData = new RangeModifiableUnlimitedArray<>();
elementData.setRange(0, data, 0, length);
elementData.end = length;
}

/**
* Precondition check is called only once by object,
* if it was passed as parameter to method under test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.utbot.engine.overrides.collections.UtHashSet
import org.utbot.engine.overrides.collections.UtLinkedList
import org.utbot.engine.overrides.UtOverrideMock
import org.utbot.engine.overrides.collections.Collection
import org.utbot.engine.overrides.collections.List
import org.utbot.engine.overrides.collections.UtGenericStorage
import org.utbot.engine.overrides.collections.UtOptional
import org.utbot.engine.overrides.collections.UtOptionalDouble
Expand Down Expand Up @@ -133,6 +134,7 @@ private val classesToLoad = arrayOf(
UtStringBuffer::class,
Stream::class,
Collection::class,
List::class,
UtStream::class,
UtStream.UtStreamIterator::class
)

0 comments on commit 1c01193

Please sign in to comment.