Skip to content

Commit

Permalink
Fix javadoc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
VanRoy committed Nov 7, 2024
1 parent b91626f commit 4dfb103
Show file tree
Hide file tree
Showing 19 changed files with 282 additions and 627 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: ./mvnw -B verify javadoc:javadoc
- name: Sonar Analysis
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
run: ./mvnw -B sonar:sonar --file pom.xml
run: ./mvnw -B sonar:sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
16 changes: 1 addition & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
</issueManagement>

<properties>
<javadocAdditionalOptions>--allow-script-in-comments</javadocAdditionalOptions>

<!-- SonarCloud -->
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>assertj</sonar.organization>
Expand Down Expand Up @@ -181,19 +179,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- (1) CSS file location -->
<stylesheetfile>src/main/javadoc/assertj-javadoc.css</stylesheetfile>
<!-- (2) Highlight Javascript file -->
<top><![CDATA[
<script src="http://cdn.jsdelivr.net/highlight.js/8.6/highlight.min.js"></script>
]]></top>
<!-- init Highlight -->
<footer><![CDATA[
<script type="text/javascript">
hljs.initHighlightingOnLoad();
</script>
]]></footer>
<additionalJOption>${javadocAdditionalOptions}</additionalJOption>
<javadocDirectory>${rootDirectory}/src/main/javadoc/</javadocDirectory>
</configuration>
</plugin>
<plugin>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/assertj/db/api/AbstractSoftAssertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
*
* @author Julien Roy
*/
public class AbstractSoftAssertions {
class AbstractSoftAssertions {

protected final SoftProxies proxies = new SoftProxies();
private final SoftProxies proxies = new SoftProxies();

public <T, V> V proxy(Class<V> assertClass, Class<T> actualClass, T actual) {
<T, V> V proxy(Class<V> assertClass, Class<T> actualClass, T actual) {
return this.proxies.create(assertClass, actualClass, actual);
}

public List<Throwable> errorsCollected() {
List<Throwable> errorsCollected() {
return Lists.newArrayList(this.proxies.errorsCollected());
}

public boolean wasSuccess() {
boolean wasSuccess() {
return this.proxies.wasSuccess();
}
}
33 changes: 33 additions & 0 deletions src/main/java/org/assertj/db/api/ErrorCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@

/**
* Collects error messages of all AssertionErrors thrown by the proxied method.
*
* @author Julien Roy
*/
public class ErrorCollector {

private static final String INTERCEPT_METHOD_NAME = "intercept";

private static final String CLASS_NAME = ErrorCollector.class.getName();

/**
* Construct empty error collector.
*/
public ErrorCollector() {
}

// scope : the current soft-assertion object
private final List<Throwable> errors = new ArrayList<>();
// scope : the last assertion call (might be nested)
Expand All @@ -48,6 +56,16 @@ private static int countErrorCollectorProxyCalls() {
return nbCalls;
}

/**
* Apply interception of assertion method to collect exception and avoid stop the assertion flow on the first error.
*
* @param assertion The assertion object proxied
* @param proxy The proxy of assertion
* @param method The method of assertion called
* @param stub The sub value if not assert method is found
* @return The current assertion object.
* @throws Exception When interception fail
*/
@RuntimeType
public Object intercept(
@This Object assertion,
Expand All @@ -73,15 +91,30 @@ public Object intercept(
return assertion;
}

/**
* Append new error to collection of errors.
*
* @param error Any throwable
*/
public void addError(Throwable error) {
errors.add(error);
lastResult.recordError();
}

/**
* Return all errors collected.
*
* @return List of exception
*/
public List<Throwable> errors() {
return Collections.unmodifiableList(errors);
}

/**
* Return if no error collected in this instance.
*
* @return true if no errors.
*/
public boolean wasSuccess() {
return lastResult.wasSuccess();
}
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/org/assertj/db/api/ProxifyPositionResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package org.assertj.db.api;

import static org.assertj.db.util.Proxies.isProxified;
import static org.assertj.db.util.Proxies.isProxied;
import static org.assertj.db.util.Proxies.unProxy;

import java.util.concurrent.Callable;
Expand Down Expand Up @@ -106,11 +106,18 @@ private static Object[] actual(Object result) {
}
}

/**
* Method called during interception of positional method.
*
* @param proxy Proxy method to use
* @return the object result proxied
* @throws Exception When method call fail
*/
@RuntimeType
public Object intercept(@SuperCall Callable<?> proxy) throws Exception {
Object result = proxy.call();

if (isProxified(result.getClass()) || Arrays.isNullOrEmpty(actual(result))) {
if (isProxied(result.getClass()) || Arrays.isNullOrEmpty(actual(result))) {
return result;
}
return this.proxies.create(result.getClass(), actualClass(result), actual(result));
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/assertj/db/api/SoftAssertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
*/
public final class SoftAssertions extends AbstractSoftAssertions {

/**
* Create a new SoftAssertions class that allow chain many assertion and detect all assertion failure ( not only the first one ).
*/
public SoftAssertions() {
super();
}

/**
* Creates a new instance of {@link TableAssert}.
*
Expand Down Expand Up @@ -62,6 +69,11 @@ public ChangesAssert assertThat(Changes changes) {
return proxy(ChangesAssert.class, Changes.class, changes);
}

/**
* Assert that all assertions succeed.
*
* @throws SoftAssertionError If any assertion failed.
*/
public void assertAll() {
List<Throwable> errors = this.errorsCollected();
if (!errors.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ private AssertionsOnRowCondition() {
// Empty
}

/**
* Verifies that the values of a row satisfy to conditions in parameter.
*
* @param <A> The type of the assertion which call this method.
* @param assertion The assertion which call this method.
* @param info Writable information about an assertion.
* @param valuesList The actual value to validate.
* @param expected The expected conditions.
* @return {@code this} assertion object.
* @throws AssertionError If the columns of the primary key are different to the names in parameters.
*/
@SuppressWarnings("unchecked")
public static <A extends AbstractAssert<?>> A hasValuesSatisfying(A assertion, WritableAssertionInfo info,
List<Value> valuesList, Object... expected) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ private AssertionsOnTableExistence() {
// Empty
}

/**
* Verifies that the table exists.
*
* @param <A> The type of the assertion which call this method.
* @param assertion The assertion which call this method.
* @param info Writable information about an assertion.
* @param table The table name to search in DB.
* @param source The source to connect to DB.
* @param dataSource The source to connect to DB.
* @return {@code this} assertion object.
* @throws AssertionError If the table does not exist.
*/
public static <A extends AbstractDbAssert<?, ?, ?, ?, ?, ?>> A exists(A assertion, WritableAssertionInfo info,
String table, Source source, DataSource dataSource) {
try (Connection connection = getConnection(source, dataSource)) {
Expand All @@ -59,6 +71,19 @@ private AssertionsOnTableExistence() {
return assertion;
}


/**
* Verifies that the database not contains the table.
*
* @param <A> The type of the assertion which call this method.
* @param assertion The assertion which call this method.
* @param info Writable information about an assertion.
* @param table The table name to search in DB.
* @param source The source to connect to DB.
* @param dataSource The source to connect to DB.
* @return {@code this} assertion object.
* @throws AssertionError If the table does not exist.
*/
public static <A extends AbstractDbAssert<?, ?, ?, ?, ?, ?>> A doesNotExists(A assertion, WritableAssertionInfo info,
String table, Source source, DataSource dataSource) {
try (Connection connection = getConnection(source, dataSource)) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/assertj/db/error/ShouldSatisfy.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ private ShouldSatisfy(int index, Object actual, Condition<?> condition) {
super(EXPECTED_MESSAGE_WITH_INDEX, index, actual, condition);
}

/**
* Verifies that the values of a row satisfy to conditions in parameter.
*
* @param index The index of properties
* @param actual The actual value that triggered assertion error.
* @param condition The condition that triggered assertion error.
* @return {@code this} condition not satisfied error message.
*/
public static ErrorMessageFactory shouldSatisfy(int index, Object actual, Condition<?> condition) {
return new ShouldSatisfy(index, actual, condition);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/assertj/db/output/impl/PlainOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public String getTableOutput(WritableAssertionInfo info, Table table) {
List<String> typesList = OutputType.getTypesList(rows);
int indexColumnSize = getIndexColumnSize(rows.length);
StringBuilder[] pksValueStringBuilders = OutputType.getPksValueStringBuilder(rows);
int primaryKeyColumnSize = getColumnSize("PRIMARY", pksValueStringBuilders);
int primaryKeyColumnSize = getColumnSize("PRIMARY", (Object[]) pksValueStringBuilders);
List<Integer> sizesList = getSizesList(rows.length == 0 ? getColumnSizesList(columnsNameList) : getColumnSizesList(rows),
indexColumnSize,
primaryKeyColumnSize);
Expand Down Expand Up @@ -481,7 +481,7 @@ public String getRequestOutput(WritableAssertionInfo info, Request request) {
List<String> typesList = OutputType.getTypesList(rows);
int indexColumnSize = getIndexColumnSize(rows.length);
StringBuilder[] pksValueStringBuilders = OutputType.getPksValueStringBuilder(rows);
int primaryKeyColumnSize = getColumnSize("PRIMARY", pksValueStringBuilders);
int primaryKeyColumnSize = getColumnSize("PRIMARY", (Object[]) pksValueStringBuilders);
List<Integer> sizesList = getSizesList(rows.length == 0 ? getColumnSizesList(columnsNameList) : getColumnSizesList(rows),
indexColumnSize,
primaryKeyColumnSize);
Expand Down Expand Up @@ -528,7 +528,7 @@ public String getChangesOutput(WritableAssertionInfo info, Changes changes) {
int changeTypeColumnSize = getChangeTypeColumnSize(changesArray);
int dataTypeColumnSize = getDataTypeColumnSize(changesArray);
StringBuilder[] pksValueStringBuilders = OutputType.getPksValueStringBuilder(changesArray);
int primaryKeyColumnSize = getColumnSize("PRIMARY", pksValueStringBuilders);
int primaryKeyColumnSize = getColumnSize("PRIMARY", (Object[]) pksValueStringBuilders);

StringBuilder stringBuilder = new StringBuilder();
// Description
Expand Down Expand Up @@ -598,7 +598,7 @@ public String getChangeOutput(WritableAssertionInfo info, Change change) {

int changeTypeColumnSize = getColumnSize("TYPE", changeType);
int dataTypeColumnSize = getColumnSize("" + dataType, dataName);
int primaryKeyColumnSize = getColumnSize("PRIMARY", pksValueStringBuilders);
int primaryKeyColumnSize = getColumnSize("PRIMARY", (Object[]) pksValueStringBuilders);
List<Integer> sizesList = getSizesList(getColumnSizesList(rowAtStartPoint, rowAtEndPoint),
changeTypeColumnSize,
dataTypeColumnSize,
Expand Down Expand Up @@ -646,7 +646,7 @@ public String getRowOutput(WritableAssertionInfo info, Row row) {
List<String> columnsNameList = row.getColumnsNameList();
List<String> typesList = OutputType.getTypesList(row);
StringBuilder[] pksValueStringBuilders = OutputType.getPksValueStringBuilder(row);
int primaryKeyColumnSize = getColumnSize("PRIMARY", pksValueStringBuilders);
int primaryKeyColumnSize = getColumnSize("PRIMARY", (Object[]) pksValueStringBuilders);
List<Integer> sizesList = getSizesList(getColumnSizesList(row),
primaryKeyColumnSize);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/assertj/db/type/DateTimeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class DateTimeValue implements Comparable<DateTimeValue>, DateValueContainer {

public static final String DATE_TIME_SHOULD_BE_NOT_NULL = "date/time should be not null";
private static final String DATE_TIME_SHOULD_BE_NOT_NULL = "date/time should be not null";
/**
* Indicates where there are the digits in the {@code String} for {@link DateValue#DateValue(String)}.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/assertj/db/type/DateValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class DateValue implements Comparable<DateValue>, DateValueContainer {

public static final String DATE_SHOULD_BE_NOT_NULL = "date should be not null";
private static final String DATE_SHOULD_BE_NOT_NULL = "date should be not null";
/**
* Indicates where there are the digits in the {@code String} for {@link DateValue#DateValue(String)}.
*/
Expand Down
Loading

0 comments on commit 4dfb103

Please sign in to comment.