Skip to content

Commit

Permalink
some cleaning : naming, javadoc, wildcard..
Browse files Browse the repository at this point in the history
  • Loading branch information
ebundy committed Dec 26, 2018
1 parent b06e796 commit e0242fd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/assertj/core/api/AbstractMapAssert.java
Expand Up @@ -1412,7 +1412,7 @@ public AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object
* @return a new assertion object whose object under test is the list of values extracted
*/
@CheckReturnValue
public AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> extractingFromEntries
public AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>> extractingFromEntries
(Function<? super Map.Entry<K, V>, Object> extractor) {

isNotNull();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/assertj/core/api/MapAssert.java
Expand Up @@ -97,12 +97,12 @@ public final MapAssert<KEY, VALUE> doesNotContain(Map.Entry<? extends KEY, ? ext

@SafeVarargs
@Override
public final AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> extracting(Function<? super Map<KEY, VALUE>, Object>... extractors) {
public final AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>> extracting(Function<? super Map<KEY, VALUE>, Object>... extractors) {
return super.extracting(extractors);
}

@Override
public final AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> extractingFromEntries(Function<? super Map.Entry<KEY, VALUE>, Object> extractor) {
public final AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>> extractingFromEntries(Function<? super Map.Entry<KEY, VALUE>, Object> extractor) {
return super.extractingFromEntries(extractor);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/assertj/core/error/ShouldNotBeNull.java
Expand Up @@ -30,8 +30,8 @@ public static ErrorMessageFactory shouldNotBeNull() {
}

/**
* Create a instance specifying the label of what should not be null
* @param label
* Create a instance specifying a label
* @param label of what should not be null
* @return the new instance
*/
public static ShouldNotBeNull of(String label) {
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/assertj/core/api/SoftAssertionsTest.java
Expand Up @@ -506,7 +506,7 @@ public void should_pass_when_using_extracting_with_list() {

@Test
@SuppressWarnings("unchecked")
public void should_pass_when_using_extractingFromEntries_with_map() {
void should_pass_when_using_extractingFromEntries_with_map() {
// GIVEN
Map<Person, List<Animal>> map = new HashMap<>();
Person aceVentura = new Person("ace ventura");
Expand All @@ -517,11 +517,11 @@ public void should_pass_when_using_extractingFromEntries_with_map() {

// WHEN
softly.assertThat(map)
.extractingFromEntries(e -> e.getKey())
.extractingFromEntries(Map.Entry::getKey)
.containsExactlyInAnyOrder(aceVentura, david);

softly.assertThat(map)
.extractingFromEntries(e -> e.getKey(), e -> e.getValue().size())
.extractingFromEntries(Map.Entry::getKey, e -> e.getValue().size())
.containsExactlyInAnyOrder(tuple(aceVentura, 1),
tuple(david, 2));

Expand All @@ -531,7 +531,7 @@ public void should_pass_when_using_extractingFromEntries_with_map() {

@Test
@SuppressWarnings("unchecked")
public void should_collect_errors_when_using_extractingFromEntries_with_map() {
void should_collect_errors_when_using_extractingFromEntries_with_map() {
// GIVEN
Map<Person, List<Animal>> map = new HashMap<>();
Person aceVentura = new Person("ace ventura");
Expand All @@ -542,7 +542,7 @@ public void should_collect_errors_when_using_extractingFromEntries_with_map() {

// WHEN
softly.assertThat(map)
.extractingFromEntries(e -> e.getKey())
.extractingFromEntries(Map.Entry::getKey)
.containsExactlyInAnyOrder(tuple(aceVentura),
tuple(new Person("stranger")));

Expand All @@ -553,7 +553,7 @@ public void should_collect_errors_when_using_extractingFromEntries_with_map() {


softly.assertThat(map)
.extractingFromEntries(e -> e.getKey(), e -> e.getValue().size())
.extractingFromEntries(Map.Entry::getKey, e -> e.getValue().size())
.containsExactlyInAnyOrder(tuple(aceVentura, 10),
tuple(david, 2));

Expand Down
Expand Up @@ -12,31 +12,31 @@
*/
package org.assertj.core.api.map;

import com.google.common.base.Function;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.provider.Arguments;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.catchThrowable;
import static org.assertj.core.api.Assertions.tuple;
import static org.assertj.core.util.FailureMessages.actualIsNull;

public class MapAssert_extractingFromEntries_Test {
class MapAssert_extractingFromEntries_Test {

private Map<Object, Object> map;

@BeforeEach
public void setup() {
void setup() {
map = new HashMap<>();
map.put("name", "bepson");
map.put("age", 10);
}

@Test
public void should_pass_assertions_on_values_extracted_from_given_extractors() {
void should_pass_assertions_on_values_extracted_from_given_extractors() {

assertThat(map).extractingFromEntries()
.contains(tuple(),
Expand All @@ -51,7 +51,7 @@ public void should_pass_assertions_on_values_extracted_from_given_extractors() {
}

@Test
public void should_keep_existing_description_if_set_when_extracting_values_list() {
void should_keep_existing_description_if_set_when_extracting_values_list() {

assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> assertThat(map).as("check name")
.extractingFromEntries(
Expand All @@ -68,19 +68,19 @@ public void should_keep_existing_description_if_set_when_extracting_values_list(
}

@Test
public void should_fail_if_actual_is_null() {
void should_fail_if_actual_is_null() {
// GIVEN
map = null;

// WHEN
Throwable error = catchThrowable(
() -> assertThat(map).extractingFromEntries(e -> e.getKey()));
() -> assertThat(map).extractingFromEntries(Map.Entry::getKey));
// THEN
assertThat(error).hasMessage(actualIsNull());

// WHEN
error = catchThrowable(
() -> assertThat(map).extractingFromEntries(e -> e.getKey(), e -> e.getValue()));
() -> assertThat(map).extractingFromEntries(Map.Entry::getKey, Map.Entry::getValue));
// THEN
assertThat(error).hasMessage(actualIsNull());

Expand Down

0 comments on commit e0242fd

Please sign in to comment.