-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* More converters + cleanup * Set additionalTestRunsOnJvmVersions in gradle.properties * Cleanup GitHub actions * Docs update * Do a clean on gradle build * Fix additional test runs on JVM versions
- Loading branch information
1 parent
57e1bc5
commit be677a8
Showing
64 changed files
with
2,076 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Contributing Guidelines | ||
|
||
First of all, thank you for having the interest in contributing to this project! | ||
|
||
## Found a bug? | ||
|
||
Please create an issue describing the following: | ||
|
||
- The version the bug was discovered. | ||
- A scenario to reproduce the bug. | ||
|
||
## Enhancement ideas? | ||
|
||
Got an idea to enhance the library? Please feel free to create an issue describing the feature proposal. Any ideas are welcome! :) | ||
|
||
## Build | ||
|
||
The project uses Java 11 as runtime for Gradle but compiles source code to Java 8. | ||
|
||
To build the project, run the command: | ||
|
||
```sh | ||
./gradlew clean build | ||
``` | ||
|
||
To create reports, run the commands: | ||
|
||
```sh | ||
./gradlew clean build testAggregateTestReport | ||
``` | ||
|
||
```sh | ||
./gradlew clean build testCodeCoverageReport | ||
``` | ||
|
||
Tests are run in multiple JVM runtimes. By default, it is run in LTS versions (succeeding the version used in source compilation) + the latest released non-LTS version. Test runtimes are overrideable by setting the `ADDITIONAL_TEST_RUNS_ON_JVM_VERSIONS` environment variable or `additionalTestRunsOnJvmVersions` system property e.g. `ADDITIONAL_TEST_RUNS_ON_JVM_VERSIONS=8,17,18` / `additionalTestRunsOnJvmVersions=8,17,18`. | ||
|
||
## Development Guidelines | ||
|
||
### Unit Test Structure | ||
|
||
Unit tests in this project follow a specific structure. | ||
|
||
- Classes must have a corresponding test class i.e. `MapResolver` -> `MapResolverTests`. The test class must be in the exact same java package as the class it corresponds to. | ||
- Test classes are nested in structure. Each method in the class under test must have a corresponding `@Nested` test class. Each `@Nested` test class must test scenarios that is supported by the method it corresponds to. | ||
|
||
```java | ||
// Class under test: io.github.joeljeremy7.externalizedproperties.resolver.my.MyResolver | ||
class MyResolver implements Resolver { | ||
public MyResolver(...) { | ||
... | ||
} | ||
|
||
public Optional<String> resolve(InvocationContext context, String propertyName) { | ||
... | ||
} | ||
|
||
public String someOtherMethod(...) { | ||
... | ||
} | ||
|
||
public static class Builder { | ||
... | ||
public MyResolver build() { | ||
... | ||
} | ||
} | ||
} | ||
|
||
// Test class: io.github.joeljeremy7.externalizedproperties.resolver.my.MyResolverTests | ||
class MyResolverTests { | ||
@Nested | ||
class Constructor { | ||
// @Test methods here... | ||
} | ||
|
||
@Nested | ||
class ResolveMethod { | ||
// @Test methods here... | ||
} | ||
|
||
@Nested | ||
class SomeOtherMethod { | ||
// @Test methods here... | ||
} | ||
|
||
// Nested class must also have corresponding test classes | ||
@Nested | ||
class BuilderTests { | ||
... | ||
@Nested | ||
class BuildMethod { | ||
// @Test methods here... | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ub/joeljeremy7/externalizedproperties/core/conversion/converters/BigDecimalConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.github.joeljeremy7.externalizedproperties.core.conversion.converters; | ||
|
||
import io.github.joeljeremy7.externalizedproperties.core.ConversionResult; | ||
import io.github.joeljeremy7.externalizedproperties.core.Converter; | ||
import io.github.joeljeremy7.externalizedproperties.core.InvocationContext; | ||
|
||
import java.lang.reflect.Type; | ||
import java.math.BigDecimal; | ||
|
||
/** | ||
* Supports conversion of values to a {@link BigDecimal}. | ||
*/ | ||
public class BigDecimalConverter implements Converter<BigDecimal> { | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public boolean canConvertTo(Class<?> targetType) { | ||
return BigDecimal.class.equals(targetType); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public ConversionResult<BigDecimal> convert( | ||
InvocationContext context, | ||
String valueToConvert, | ||
Type targetType | ||
) { | ||
return ConversionResult.of(new BigDecimal(valueToConvert)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ub/joeljeremy7/externalizedproperties/core/conversion/converters/BigIntegerConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.github.joeljeremy7.externalizedproperties.core.conversion.converters; | ||
|
||
import io.github.joeljeremy7.externalizedproperties.core.ConversionResult; | ||
import io.github.joeljeremy7.externalizedproperties.core.Converter; | ||
import io.github.joeljeremy7.externalizedproperties.core.InvocationContext; | ||
|
||
import java.lang.reflect.Type; | ||
import java.math.BigInteger; | ||
|
||
/** | ||
* Supports conversion of values to a {@link BigInteger}. | ||
*/ | ||
public class BigIntegerConverter implements Converter<BigInteger> { | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public boolean canConvertTo(Class<?> targetType) { | ||
return BigInteger.class.equals(targetType); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public ConversionResult<BigInteger> convert( | ||
InvocationContext context, | ||
String valueToConvert, | ||
Type targetType | ||
) { | ||
return ConversionResult.of(new BigInteger(valueToConvert)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
.../github/joeljeremy7/externalizedproperties/core/conversion/converters/ClassConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.github.joeljeremy7.externalizedproperties.core.conversion.converters; | ||
|
||
import io.github.joeljeremy7.externalizedproperties.core.ConversionResult; | ||
import io.github.joeljeremy7.externalizedproperties.core.Converter; | ||
import io.github.joeljeremy7.externalizedproperties.core.InvocationContext; | ||
import io.github.joeljeremy7.externalizedproperties.core.conversion.ConversionException; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
/** | ||
* Supports conversion of values to a {@link Class}. | ||
*/ | ||
public class ClassConverter implements Converter<Class<?>> { | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public boolean canConvertTo(Class<?> targetType) { | ||
return Class.class.equals(targetType); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public ConversionResult<Class<?>> convert( | ||
InvocationContext context, | ||
String valueToConvert, | ||
Type targetType | ||
) { | ||
try { | ||
return ConversionResult.of(Class.forName(valueToConvert)); | ||
} catch (ClassNotFoundException e) { | ||
throw new ConversionException( | ||
String.format("Failed to load as Class: %s", valueToConvert), | ||
e | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.