Skip to content

Commit

Permalink
Add module descriptor to assertj-guava, move tests to separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
scordio committed May 15, 2024
1 parent 2c695fc commit b7b5ec4
Show file tree
Hide file tree
Showing 94 changed files with 301 additions and 222 deletions.
6 changes: 0 additions & 6 deletions assertj-guava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
25 changes: 25 additions & 0 deletions assertj-guava/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright 2012-2024 the original author or authors.
*/

/**
* AssertJ extension for Guava assertions.
*/
module org.assertj.guava {
requires transitive org.assertj.core;
requires com.google.common;

exports org.assertj.guava.api;
exports org.assertj.guava.data;
exports org.assertj.guava.error;
exports org.assertj.guava.util;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.assertj</groupId>
<artifactId>assertj-integration-tests</artifactId>
<version>3.26.0-SNAPSHOT</version>
</parent>

<artifactId>assertj-guava-module-path</artifactId>

<name>AssertJ Guava Integration Tests - Module Path</name>

<properties>
<rootDirectory>${project.basedir}/../../../</rootDirectory>
<spotless.skip>false</spotless.skip>
</properties>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.0-jre</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-guava</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright 2012-2024 the original author or authors.
*/
open module org.assertj.test.guava {
requires com.google.common;
requires org.assertj.guava;
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static org.assertj.core.api.BDDAssertions.then;
import static org.assertj.guava.api.Assertions.assertThat;

import org.assertj.guava.api.MultimapAssert;
import org.junit.jupiter.api.Test;

import com.google.common.collect.HashMultimap;
Expand All @@ -35,14 +36,4 @@ void should_create_Assert() {
then(assertion).isNotNull();
}

@Test
void should_pass_actual() {
// GIVEN
Multimap<String, String> actual = HashMultimap.create();
// WHEN
Multimap<String, String> result = assertThat(actual).getActual();
// THEN
then(result).isSameAs(actual);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static org.assertj.core.api.BDDAssertions.then;
import static org.assertj.guava.api.Assertions.assertThat;

import org.assertj.guava.api.OptionalAssert;
import org.junit.jupiter.api.Test;

import com.google.common.base.Optional;

/**
* @author Joel Costigliola
*/
@SuppressWarnings("Guava")
class Assertions_assertThat_with_Optional_Test {

@Test
Expand All @@ -35,14 +35,4 @@ void should_create_Assert() {
then(assertion).isNotNull();
}

@Test
void should_pass_actual() {
// GIVEN
Optional<String> actual = Optional.of("value");
// WHEN
Optional<String> result = assertThat(actual).getActual();
// THEN
then(result).isSameAs(actual);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static java.util.stream.Collectors.toMap;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -34,6 +34,11 @@
import java.util.stream.Stream;

import org.assertj.core.api.InstanceOfAssertFactory;
import org.assertj.guava.api.Assertions;
import org.assertj.guava.api.InstanceOfAssertFactories;
import org.assertj.guava.api.RangeAssert;
import org.assertj.guava.api.RangeMapAssert;
import org.assertj.guava.api.RangeSetAssert;
import org.junit.jupiter.api.Test;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static org.assertj.core.api.BDDAssertions.then;
import static org.assertj.core.util.FailureMessages.actualIsNull;
import static org.assertj.guava.api.Assertions.assertThat;
import static org.assertj.guava.error.ShouldHaveSameContent.shouldHaveSameContent;
import static org.assertj.guava.testkit.AssertionErrors.expectAssertionError;
import static org.assertj.guava.tests.testkit.AssertionErrors.expectAssertionError;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.MapEntry.entry;
Expand All @@ -29,6 +29,15 @@

import java.io.IOException;

import org.assertj.guava.api.Assertions;
import org.assertj.guava.api.ByteSourceAssert;
import org.assertj.guava.api.MultimapAssert;
import org.assertj.guava.api.MultisetAssert;
import org.assertj.guava.api.OptionalAssert;
import org.assertj.guava.api.RangeAssert;
import org.assertj.guava.api.RangeMapAssert;
import org.assertj.guava.api.RangeSetAssert;
import org.assertj.guava.api.TableAssert;
import org.junit.jupiter.api.Test;

import com.google.common.base.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static com.google.common.collect.Lists.newArrayList;

Expand All @@ -35,4 +35,4 @@ public void setUp() {
actual.putAll("Spurs", newArrayList("Tony Parker", "Tim Duncan", "Manu Ginobili"));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.catchThrowable;
Expand All @@ -20,8 +20,8 @@
import static org.assertj.core.util.FailureMessages.actualIsNull;
import static org.assertj.core.util.Lists.list;
import static org.assertj.guava.api.Assertions.assertThat;
import static org.assertj.guava.testkit.AssertionErrors.expectAssertionError;

import org.assertj.guava.tests.testkit.AssertionErrors;
import org.junit.jupiter.api.Test;

import com.google.common.collect.HashMultimap;
Expand Down Expand Up @@ -76,7 +76,7 @@ void should_fail_if_actual_is_null() {
// GIVEN
actual = null;
// WHEN
AssertionError error = expectAssertionError(() -> assertThat(actual).containsAllEntriesOf(other));
AssertionError error = AssertionErrors.expectAssertionError(() -> assertThat(actual).containsAllEntriesOf(other));
// THEN
then(error).hasMessage(actualIsNull());
}
Expand All @@ -100,7 +100,7 @@ void should_fail_if_actual_does_not_contain_all_given_multimap_entries() {
other.putAll("Spurs", newArrayList("Tony Parker", "Tim Duncan", "Manu Ginobili"));
other.putAll("Warriors", newArrayList("Stephen Curry", "Klay Thompson"));
// WHEN
AssertionError error = expectAssertionError(() -> assertThat(actual).containsAllEntriesOf(other));
AssertionError error = AssertionErrors.expectAssertionError(() -> assertThat(actual).containsAllEntriesOf(other));
// THEN
then(error).hasMessage(shouldContain(actual, other,
list(entry("Warriors", "Stephen Curry"), entry("Warriors", "Klay Thompson"))).create());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright 2012-2024 the original author or authors.
*/
package org.assertj.guava.api;
package org.assertj.guava.tests.api;

import static java.util.Collections.singleton;
import static org.assertj.core.api.Assertions.catchThrowable;
Expand All @@ -20,9 +20,9 @@
import static org.assertj.core.util.Arrays.array;
import static org.assertj.core.util.FailureMessages.actualIsNull;
import static org.assertj.guava.api.Assertions.assertThat;
import static org.assertj.guava.testkit.AssertionErrors.expectAssertionError;

import org.assertj.core.data.MapEntry;
import org.assertj.guava.tests.testkit.AssertionErrors;
import org.junit.jupiter.api.Test;

class MultimapAssert_contains_Test extends MultimapAssertBaseTest {
Expand All @@ -38,7 +38,7 @@ void should_fail_if_actual_is_null() {
// GIVEN
actual = null;
// WHEN
AssertionError error = expectAssertionError(() -> assertThat(actual).contains(entry("Lakers", "Kobe Bryant")));
AssertionError error = AssertionErrors.expectAssertionError(() -> assertThat(actual).contains(entry("Lakers", "Kobe Bryant")));
// THEN
then(error).hasMessage(actualIsNull());
}
Expand Down Expand Up @@ -68,7 +68,7 @@ void should_fail_if_actual_does_not_contain_all_given_entries() {
// GIVEN
MapEntry<String, String>[] entries = array(entry("Lakers", "Kobe Bryant"), entry("Spurs", "Derrick Rose"));
// WHEN
AssertionError error = expectAssertionError(() -> assertThat(actual).contains(entries));
AssertionError error = AssertionErrors.expectAssertionError(() -> assertThat(actual).contains(entries));
// THEN
then(error).hasMessage(shouldContain(actual, entries, singleton(entry("Spurs", "Derrick Rose"))).create());
}
Expand Down

0 comments on commit b7b5ec4

Please sign in to comment.