Skip to content

Commit 7dd6667

Browse files
Start of Multimap Assertions (#1)
Setting up the skeleton of the MultimapAssert type --------- Co-authored-by: Stefano Cordio <[email protected]>
1 parent 63c65f1 commit 7dd6667

29 files changed

+2329
-35
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# AssertJ Eclipse Collections [![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
2+
3+
[![CI](https://github.com/assertj/assertj/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/assertj/assertj/actions/workflows/main.yml?query=branch%3Amain)

pom.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
</license>
2424
</licenses>
2525

26+
<developers>
27+
<developer>
28+
<id>mattbertolini</id>
29+
<name>Matt Bertolini</name>
30+
<url>https://github.com/mattbertolini</url>
31+
</developer>
32+
</developers>
33+
2634
<scm>
2735
<connection>scm:git:https://github.com/assertj/assertj-eclipse-collections.git</connection>
2836
<developerConnection>scm:git:https://github.com/assertj/assertj-eclipse-collections.git</developerConnection>
@@ -31,9 +39,10 @@
3139

3240
<properties>
3341
<assertj.version>3.27.3</assertj.version>
42+
<java.version>11</java.version>
3443
<eclipse-collections.version>13.0.0</eclipse-collections.version>
3544
<!-- Dependency versions overriding -->
36-
<junit-jupiter.version>5.11.4</junit-jupiter.version>
45+
<junit-jupiter.version>5.12.1</junit-jupiter.version>
3746
</properties>
3847

3948
<dependencies>
@@ -46,10 +55,16 @@
4655
<!-- Provided -->
4756
<dependency>
4857
<groupId>org.eclipse.collections</groupId>
49-
<artifactId>eclipse-collections-api</artifactId>
58+
<artifactId>eclipse-collections</artifactId>
5059
<version>${eclipse-collections.version}</version>
5160
<scope>provided</scope>
5261
</dependency>
62+
<dependency>
63+
<groupId>org.opentest4j</groupId>
64+
<artifactId>opentest4j</artifactId>
65+
<scope>provided</scope>
66+
<optional>true</optional>
67+
</dependency>
5368
<!-- Test -->
5469
<dependency>
5570
<groupId>org.junit.jupiter</groupId>

src/main/java/org/assertj/eclipse/collections/Main.java

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
3+
* the License. You may obtain a copy of the License at
4+
*
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
* specific language governing permissions and limitations under the License.
10+
*
11+
* Copyright 2025-2025 the original author or authors.
12+
*/
13+
package org.assertj.eclipse.collections.api;
14+
15+
import org.assertj.core.util.CheckReturnValue;
16+
import org.assertj.eclipse.collections.api.multimap.MultimapAssert;
17+
import org.eclipse.collections.api.multimap.Multimap;
18+
19+
/**
20+
* Entry point for assertion methods for the Eclipse Collections library. Each method in this class is a static factory
21+
* for a type-specific assertion object.
22+
*/
23+
@CheckReturnValue
24+
public class Assertions {
25+
/**
26+
* Creates a new {@link Assertions}.
27+
*/
28+
protected Assertions() {
29+
// Do nothing
30+
}
31+
32+
/**
33+
* Creates a new instance of {@link MultimapAssert}.
34+
*
35+
* @param actual the actual value.
36+
* @return the created assertion object.
37+
* @param <KEY> The type of keys in the BagMultimap
38+
* @param <VALUE> The type of values in the BagMultimap
39+
*/
40+
public static <KEY, VALUE> MultimapAssert<KEY, VALUE> assertThat(Multimap<KEY, VALUE> actual) {
41+
return new MultimapAssert<>(actual);
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
3+
* the License. You may obtain a copy of the License at
4+
*
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
* specific language governing permissions and limitations under the License.
10+
*
11+
* Copyright 2025-2025 the original author or authors.
12+
*/
13+
package org.assertj.eclipse.collections.api;
14+
15+
import org.assertj.core.util.CheckReturnValue;
16+
import org.assertj.eclipse.collections.api.multimap.MultimapAssert;
17+
import org.eclipse.collections.api.multimap.Multimap;
18+
19+
/**
20+
* Behavior-driven development style entry point for assertion methods for the Eclipse Collections library. Each method
21+
* in this class is a static factory for a type-specific assertion object.
22+
*/
23+
@CheckReturnValue
24+
public class BDDAssertions extends Assertions {
25+
/**
26+
* Creates a new <code>{@link BDDAssertions}</code>.
27+
*/
28+
protected BDDAssertions() {
29+
// Do nothing
30+
}
31+
32+
/**
33+
* Creates a new instance of {@link MultimapAssert}.
34+
*
35+
* @param actual the actual value.
36+
* @return the created assertion object.
37+
* @param <KEY> The type of keys in the BagMultimap
38+
* @param <VALUE> The type of values in the BagMultimap
39+
*/
40+
public static <KEY, VALUE> MultimapAssert<KEY, VALUE> then(Multimap<KEY, VALUE> actual) {
41+
return assertThat(actual);
42+
}
43+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
3+
* the License. You may obtain a copy of the License at
4+
*
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
* specific language governing permissions and limitations under the License.
10+
*
11+
* Copyright 2025-2025 the original author or authors.
12+
*/
13+
package org.assertj.eclipse.collections.api;
14+
15+
import org.assertj.core.api.SoftAssertionsProvider;
16+
import org.assertj.core.util.CheckReturnValue;
17+
import org.assertj.eclipse.collections.api.multimap.MultimapAssert;
18+
import org.eclipse.collections.api.multimap.Multimap;
19+
20+
/**
21+
* Soft assertions implementations for Eclipse Collections types.
22+
*/
23+
@CheckReturnValue
24+
public interface EclipseCollectionsSoftAssertionsProvider extends SoftAssertionsProvider {
25+
/**
26+
* Creates a new, proxied instance of a {@link MultimapAssert}
27+
*
28+
* @param actual the path
29+
* @return the created assertion object
30+
* @param <KEY> The type of keys in the actual BagMultimap
31+
* @param <VALUE> The type of values in the actual BagMultimap
32+
*/
33+
@SuppressWarnings("unchecked")
34+
default <KEY, VALUE> MultimapAssert<KEY, VALUE> assertThat(Multimap<KEY, VALUE> actual) {
35+
return this.proxy(MultimapAssert.class, Multimap.class, actual);
36+
}
37+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
3+
* the License. You may obtain a copy of the License at
4+
*
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
* specific language governing permissions and limitations under the License.
10+
*
11+
* Copyright 2025-2025 the original author or authors.
12+
*/
13+
package org.assertj.eclipse.collections.api;
14+
15+
import org.assertj.core.api.AbstractSoftAssertions;
16+
import org.assertj.core.api.SoftAssertionsProvider;
17+
import org.opentest4j.MultipleFailuresError;
18+
19+
import java.util.function.Consumer;
20+
21+
/**
22+
* A soft assertions provider for Eclipse Collections assertions
23+
*/
24+
public class SoftAssertions extends AbstractSoftAssertions implements EclipseCollectionsSoftAssertionsProvider {
25+
/**
26+
* Creates a new {@link SoftAssertions}.
27+
*/
28+
public SoftAssertions() {
29+
// Do nothing
30+
}
31+
32+
/**
33+
* Convenience method for calling {@link EclipseCollectionsSoftAssertionsProvider#assertSoftly} for these assertion
34+
* types. Equivalent to {@code SoftAssertion.assertSoftly(SoftAssertions.class, softly)}.
35+
*
36+
* @param softly the Consumer containing the code that will make the soft assertions.
37+
* Takes one parameter (the SoftAssertions instance used to make the assertions).
38+
* @throws MultipleFailuresError if possible or SoftAssertionError if any proxied assertion objects threw an {@link
39+
* AssertionError}
40+
*/
41+
public static void assertSoftly(Consumer<SoftAssertions> softly) {
42+
SoftAssertionsProvider.assertSoftly(SoftAssertions.class, softly);
43+
}
44+
}

0 commit comments

Comments
 (0)