Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie committed Feb 15, 2022
1 parent 4b1eee7 commit ddbf8c7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
final class AssertJMapTemplates {
private AssertJMapTemplates() {}

static final class AbstractMapAssertContainsExactlyEntriesOf<K, V> {
static final class AbstractMapAssertContainsExactlyInAnyOrderEntriesOf<K, V> {
@BeforeTemplate
AbstractMapAssert<?, ?, K, V> before(AbstractMapAssert<?, ?, K, V> mapAssert, Map<K, V> map) {
return mapAssert.isEqualTo(map);
Expand All @@ -21,15 +21,15 @@ static final class AbstractMapAssertContainsExactlyEntriesOf<K, V> {
}
}

static final class AbstractMapAssertContainsOnly<K, V> {
static final class AbstractMapAssertContainsExactlyEntriesOf<K, V> {
@BeforeTemplate
AbstractMapAssert<?, ?, K, V> before(AbstractMapAssert<?, ?, K, V> mapAssert, K key, V value) {
return mapAssert.containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(key, value));
}

@AfterTemplate
AbstractMapAssert<?, ?, K, V> after(AbstractMapAssert<?, ?, K, V> mapAssert, K key, V value) {
return mapAssert.containsOnly(Map.entry(key, value));
return mapAssert.containsExactlyEntriesOf(ImmutableMap.of(key, value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import org.assertj.core.api.AbstractMapAssert;

final class AssertJMapTemplatesTest implements RefasterTemplateTestCase {
AbstractMapAssert<?, ?, Integer, Integer> testAbstractMapAssertContainsExactlyEntriesOf() {
AbstractMapAssert<?, ?, Integer, Integer>
testAbstractMapAssertContainsExactlyInAnyOrderEntriesOf() {
return assertThat(ImmutableMap.of(1, 2, 3, 4)).isEqualTo(ImmutableMap.of(1, 2, 3, 4));
}

AbstractMapAssert<?, ?, Integer, Integer> testAbstractMapAssertContainsOnly() {
AbstractMapAssert<?, ?, Integer, Integer> testAbstractMapAssertContainsExactlyEntriesOf() {
return assertThat(ImmutableMap.of(1, 2))
.containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import static org.assertj.core.api.Assertions.assertThat;

import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.assertj.core.api.AbstractMapAssert;

final class AssertJMapTemplatesTest implements RefasterTemplateTestCase {
AbstractMapAssert<?, ?, Integer, Integer> testAbstractMapAssertContainsExactlyEntriesOf() {
AbstractMapAssert<?, ?, Integer, Integer>
testAbstractMapAssertContainsExactlyInAnyOrderEntriesOf() {
return assertThat(ImmutableMap.of(1, 2, 3, 4))
.containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(1, 2, 3, 4));
}

AbstractMapAssert<?, ?, Integer, Integer> testAbstractMapAssertContainsOnly() {
return assertThat(ImmutableMap.of(1, 2)).containsOnly(Map.entry(1, 2));
AbstractMapAssert<?, ?, Integer, Integer> testAbstractMapAssertContainsExactlyEntriesOf() {
return assertThat(ImmutableMap.of(1, 2)).containsExactlyEntriesOf(ImmutableMap.of(1, 2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,24 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
ImmutableSet<NumberAssert<?, ?>> testAssertThatIsOdd() {
return ImmutableSet.of(
assertThat((byte) 1 % 2).isEqualTo(1),
assertThat((Integer) 1 % 2).isEqualTo(1),
assertThat(Byte.valueOf((byte) 1) % 2).isEqualTo(1),
assertThat((int) 1 % 2).isEqualTo(1),
assertThat(Integer.valueOf(1) % 2).isEqualTo(1),
assertThat((long) 1 % 2).isEqualTo(1),
assertThat((short) 1 % 2).isEqualTo(1));
assertThat(Long.valueOf(1L) % 2).isEqualTo(1),
assertThat((short) 1 % 2).isEqualTo(1),
assertThat(Short.valueOf((short) 1) % 2).isEqualTo(1));
}

ImmutableSet<NumberAssert<?, ?>> testAssertThatIsEven() {
return ImmutableSet.of(
assertThat((byte) 1 % 2).isEqualTo(0),
assertThat((Integer) 1 % 2).isEqualTo(0),
assertThat(Byte.valueOf((byte) 1) % 2).isEqualTo(0),
assertThat((int) 1 % 2).isEqualTo(0),
assertThat(Integer.valueOf(1) % 2).isEqualTo(0),
assertThat((long) 1 % 2).isEqualTo(0),
assertThat((short) 1 % 2).isEqualTo(0));
assertThat(Long.valueOf(1L) % 2).isEqualTo(0),
assertThat((short) 1 % 2).isEqualTo(0),
assertThat(Short.valueOf((short) 1) % 2).isEqualTo(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,24 @@ final class AssertJNumberTemplatesTest implements RefasterTemplateTestCase {
ImmutableSet<NumberAssert<?, ?>> testAssertThatIsOdd() {
return ImmutableSet.of(
assertThat((byte) 1).isOdd(),
assertThat((Integer) 1).isOdd(),
assertThat(Byte.valueOf((byte) 1)).isOdd(),
assertThat((int) 1).isOdd(),
assertThat(Integer.valueOf(1)).isOdd(),
assertThat((long) 1).isOdd(),
assertThat((short) 1).isOdd());
assertThat(Long.valueOf(1L)).isOdd(),
assertThat((short) 1).isOdd(),
assertThat(Short.valueOf((short) 1)).isOdd());
}

ImmutableSet<NumberAssert<?, ?>> testAssertThatIsEven() {
return ImmutableSet.of(
assertThat((byte) 1).isEven(),
assertThat((Integer) 1).isEven(),
assertThat(Byte.valueOf((byte) 1)).isEven(),
assertThat((int) 1).isEven(),
assertThat(Integer.valueOf(1)).isEven(),
assertThat((long) 1).isEven(),
assertThat((short) 1).isEven());
assertThat(Long.valueOf(1L)).isEven(),
assertThat((short) 1).isEven(),
assertThat(Short.valueOf((short) 1)).isEven());
}
}

0 comments on commit ddbf8c7

Please sign in to comment.