Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSejin committed Apr 10, 2022
2 parents 03c043a + a244d7e commit b348a42
Show file tree
Hide file tree
Showing 96 changed files with 5,335 additions and 2,072 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,21 @@ jobs:

runs-on: ${{ matrix.os }}

env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
distribution: "adopt"

- name: Build with Maven
run: mvn clean package -B --file pom.xml

- name: Send code coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
# Not required for public repository.
# token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</a>
-->
<a href="https://github.com/ImSejin/common-utils/actions/workflows/maven-build.yml">
<img alt="Github Workflows" src="https://img.shields.io/github/workflow/status/imsejin/common-utils/Java%20CI%20with%20Maven?label=build&style=flat-square">
<img alt="GitHub Workflow" src="https://img.shields.io/github/workflow/status/ImSejin/common-utils/Java%20CI%20with%20Maven/release?style=flat-square">
</a>
<a href="https://codecov.io/gh/ImSejin/common-utils">
<img alt="Codecov branch" src="https://img.shields.io/codecov/c/github/ImSejin/common-utils/release?label=code%20coverage&style=flat-square&token=F9DCS57CAN"/>
Expand Down
19 changes: 10 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.imsejin</groupId>
<artifactId>common-utils</artifactId>
<version>0.7.1</version>
<version>0.8.0</version>
<packaging>jar</packaging>

<name>Common Utils</name>
Expand Down Expand Up @@ -53,17 +53,18 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<junit5.version>5.8.1</junit5.version>
<assertj.version>3.21.0</assertj.version>
<spock.version>2.0-groovy-3.0</spock.version>
<!-- Dependencies -->
<junit5.version>5.8.2</junit5.version>
<assertj.version>3.22.0</assertj.version>
<spock.version>2.1-groovy-3.0</spock.version>
</properties>

<dependencies>
<!-- Gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.7</version>
<version>2.9.0</version>
</dependency>

<!--Ini4j -->
Expand Down Expand Up @@ -208,7 +209,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.2</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down Expand Up @@ -246,7 +247,7 @@
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.13.0</version>
<version>1.13.1</version>
<executions>
<execution>
<goals>
Expand All @@ -261,7 +262,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand All @@ -276,7 +277,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<version>0.8.8</version>
<executions>
<execution>
<goals>
Expand Down
187 changes: 85 additions & 102 deletions src/main/java/io/github/imsejin/common/assertion/Asserts.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@

package io.github.imsejin.common.assertion;

import io.github.imsejin.common.assertion.array.ArrayAssert;
import io.github.imsejin.common.assertion.chars.AbstractCharSequenceAssert;
import io.github.imsejin.common.assertion.chars.StringAssert;
import io.github.imsejin.common.assertion.collection.AbstractCollectionAssert;
import io.github.imsejin.common.assertion.io.AbstractFileAssert;
import io.github.imsejin.common.assertion.map.AbstractMapAssert;
import io.github.imsejin.common.assertion.lang.*;
import io.github.imsejin.common.assertion.math.BigDecimalAssert;
import io.github.imsejin.common.assertion.object.AbstractObjectAssert;
import io.github.imsejin.common.assertion.primitive.*;
import io.github.imsejin.common.assertion.reflect.ClassAssert;
import io.github.imsejin.common.assertion.reflect.PackageAssert;
import io.github.imsejin.common.assertion.time.*;
import io.github.imsejin.common.assertion.time.chrono.AbstractChronoLocalDateAssert;
import io.github.imsejin.common.assertion.time.chrono.AbstractChronoLocalDateTimeAssert;
import io.github.imsejin.common.assertion.time.chrono.AbstractChronoZonedDateTimeAssert;
import io.github.imsejin.common.assertion.util.CollectionAssert;
import io.github.imsejin.common.assertion.util.MapAssert;
import io.github.imsejin.common.util.ArrayUtils;

import java.io.File;
Expand All @@ -43,19 +37,20 @@
import java.util.Map;

/**
* Asserts
* <p>
* This is implemented similarly to AssertJ's API.
* <p>
* If you use the '{@code ACTUAL}' generic variable directly within an assertion class as a parameter,
* user code that use the assertion class can't be compiled because its bound type does not match
* the generic variable.
* <p>
* AssertJ solved this problem by <u>specifying the generic type of a class that inherited the assertion
* class</u>. There is a difference between this and AssertJ. This solved the problem by <u>specifying
* the generic type in method return type and instantiating an anonymous class that inherited
* the assertion class <b>with raw type because the diamond operator is not supported on anonymous classes
* until Java 8</b></u>.
* Asserts for fluent assertion not increasing branches in code coverage.
*
* <p> This is implemented similarly to AssertJ's API.
*
* <p> If you use the '{@code ACTUAL}' type variable directly within an assertion
* class as a parameter, user code that use the assertion class can't be compiled
* because its bound type does not match the type variable.
*
* <p> AssertJ solved this problem by <u>specifying the generic type of a class
* that extends the assertion class</u>. There is a difference between this
* and AssertJ. This solved the problem by <u>specifying the type variable in return
* type of method and instantiating an anonymous class that extends the assertion
* class <b>with raw type because the diamond operator is not supported on anonymous
* classes until Java 8</b></u>.
*
* @see <a href="https://assertj.github.io/doc/">AssertJ API document</a>
*/
Expand All @@ -68,85 +63,48 @@ public abstract class Asserts {
protected Asserts() {
}

//////////////////////////////////////// Array ////////////////////////////////////////

public static ArrayAssert<?> that(boolean[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
}

public static ArrayAssert<?> that(byte[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
}

public static ArrayAssert<?> that(char[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
}

public static ArrayAssert<?> that(double[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
}
//////////////////////////////////////// java.lang ////////////////////////////////////////

public static ArrayAssert<?> that(float[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
public static <T> ObjectAssert<?, T> that(T object) {
return new ObjectAssert<>(object);
}

public static ArrayAssert<?> that(int[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
public static ArrayAssert<?, Boolean> that(boolean[] array) {
return that((Boolean[]) ArrayUtils.wrap(array));
}

public static ArrayAssert<?> that(long[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
public static ArrayAssert<?, Byte> that(byte[] array) {
return that((Byte[]) ArrayUtils.wrap(array));
}

public static ArrayAssert<?> that(short[] array) {
return new ArrayAssert<>(array == null ? null : ArrayUtils.box(array));
public static ArrayAssert<?, Short> that(short[] array) {
return that((Short[]) ArrayUtils.wrap(array));
}

public static <T> ArrayAssert<?> that(T[] array) {
return new ArrayAssert<>(array);
public static ArrayAssert<?, Character> that(char[] array) {
return that((Character[]) ArrayUtils.wrap(array));
}

///////////////////////////////////// Characters //////////////////////////////////////

public static AbstractCharSequenceAssert<?, CharSequence> that(CharSequence charSequence) {
return new AbstractCharSequenceAssert(charSequence) {
};
public static ArrayAssert<?, Integer> that(int[] array) {
return that((Integer[]) ArrayUtils.wrap(array));
}

public static StringAssert<?> that(String string) {
return new StringAssert<>(string);
public static ArrayAssert<?, Long> that(long[] array) {
return that((Long[]) ArrayUtils.wrap(array));
}

///////////////////////////////////// Collection //////////////////////////////////////

public static <T> AbstractCollectionAssert<?, Collection<T>, T> that(Collection<T> collection) {
return new AbstractCollectionAssert(collection) {
};
public static ArrayAssert<?, Float> that(float[] array) {
return that((Float[]) ArrayUtils.wrap(array));
}

//////////////////////////////////// Input/Output /////////////////////////////////////

public static AbstractFileAssert<?, File> that(File file) {
return new AbstractFileAssert(file) {
};
public static ArrayAssert<?, Double> that(double[] array) {
return that((Double[]) ArrayUtils.wrap(array));
}

///////////////////////////////////////// Map /////////////////////////////////////////

public static <K, V> AbstractMapAssert<?, Map<K, V>, K, V> that(Map<K, V> map) {
return new AbstractMapAssert(map) {
};
}

/////////////////////////////////////// Object ////////////////////////////////////////

public static <T> AbstractObjectAssert<?, T> that(T object) {
return new AbstractObjectAssert(object) {
};
public static <T> ArrayAssert<?, T> that(T[] array) {
return new ArrayAssert<>(array);
}

////////////////////////////////////// Primitive //////////////////////////////////////

public static BooleanAssert<?> that(Boolean bool) {
return new BooleanAssert<>(bool);
}
Expand All @@ -155,25 +113,25 @@ public static CharacterAssert<?> that(Character character) {
return new CharacterAssert<>(character);
}

/////////////////////////////////////// Number ////////////////////////////////////////

public static BigDecimalAssert<?> that(BigDecimal number) {
return new BigDecimalAssert<>(number);
public static FloatAssert<?> that(Float number) {
return new FloatAssert<>(number);
}

public static DoubleAssert<?> that(Double number) {
return new DoubleAssert<>(number);
}

public static FloatAssert<?> that(Float number) {
return new FloatAssert<>(number);
}

public static <NUMBER extends Number & Comparable<NUMBER>> NumberAssert<?, NUMBER> that(NUMBER number) {
return new NumberAssert<>(number);
}

///////////////////////////////////// Reflection //////////////////////////////////////
public static CharSequenceAssert<?, CharSequence> that(CharSequence charSequence) {
return new CharSequenceAssert<>(charSequence);
}

public static StringAssert<?> that(String string) {
return new StringAssert<>(string);
}

public static <T> ClassAssert<?, T> that(Class<T> type) {
return new ClassAssert<>(type);
Expand All @@ -183,7 +141,30 @@ public static PackageAssert<?> that(Package pack) {
return new PackageAssert<>(pack);
}

//////////////////////////////////////// Time /////////////////////////////////////////
///////////////////////////////////// java.util //////////////////////////////////////

public static <T> CollectionAssert<?, Collection<T>, T> that(Collection<T> collection) {
return new CollectionAssert<>(collection);
}

public static <K, V> MapAssert<?, Map<K, V>, K, V> that(Map<K, V> map) {
return new MapAssert<>(map);
}

//////////////////////////////////// java.io /////////////////////////////////////

public static AbstractFileAssert<?, File> that(File file) {
return new AbstractFileAssert(file) {
};
}

/////////////////////////////////////// java.math ////////////////////////////////////////

public static BigDecimalAssert<?> that(BigDecimal number) {
return new BigDecimalAssert<>(number);
}

//////////////////////////////////////// java.time /////////////////////////////////////////

public static InstantAssert<?> that(Instant instant) {
return new InstantAssert(instant);
Expand All @@ -197,6 +178,20 @@ public static YearMonthAssert<?> that(YearMonth yearMonth) {
return new YearMonthAssert(yearMonth);
}

public static LocalTimeAssert<?> that(LocalTime time) {
return new LocalTimeAssert<>(time);
}

public static OffsetDateTimeAssert<?> that(OffsetDateTime dateTime) {
return new OffsetDateTimeAssert<>(dateTime);
}

public static OffsetTimeAssert<?> that(OffsetTime time) {
return new OffsetTimeAssert<>(time);
}

//////////////////////////////////////// java.time.chrono /////////////////////////////////////////

public static AbstractChronoLocalDateAssert<?> that(ChronoLocalDate date) {
return new AbstractChronoLocalDateAssert(date) {
};
Expand All @@ -212,16 +207,4 @@ public static <DATE extends ChronoLocalDate> AbstractChronoZonedDateTimeAssert<?
};
}

public static LocalTimeAssert<?> that(LocalTime time) {
return new LocalTimeAssert<>(time);
}

public static OffsetDateTimeAssert<?> that(OffsetDateTime dateTime) {
return new OffsetDateTimeAssert<>(dateTime);
}

public static OffsetTimeAssert<?> that(OffsetTime time) {
return new OffsetTimeAssert<>(time);
}

}
Loading

0 comments on commit b348a42

Please sign in to comment.