Finding the Minimum Value in an ArrayList along with the Index Number… (#13498)
* Finding the Minimum Value in an ArrayList along with the Index Number in Java * BAEL-6147: rename test unit method * adapt test method name
This commit is contained in:
parent
f5fa90c236
commit
e8fe289f85
@ -6,6 +6,7 @@ import com.baeldung.java_8_features.Person;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
@ -71,4 +72,17 @@ public class Java8MaxMinUnitTest {
|
||||
|
||||
assertEquals(bugatti, maxBySpeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIntegerList_whenGetMinAndIndex_thenSuccess() {
|
||||
final List<Integer> listOfIntegers = Arrays.asList(11, 13, 9, 20, 7, 3, 30);
|
||||
final Integer expectedMinValue = 3;
|
||||
final Integer expectedMinIndex = 5;
|
||||
|
||||
Integer minValue = Collections.min(listOfIntegers);
|
||||
Integer minIndex = listOfIntegers.indexOf(minValue);
|
||||
|
||||
assertEquals(minValue, expectedMinValue);
|
||||
assertEquals(minIndex, expectedMinIndex);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user