Skip to content

Commit be677a8

Browse files
authored
More converters + cleanup (#53)
* 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
1 parent 57e1bc5 commit be677a8

File tree

64 files changed

+2076
-485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2076
-485
lines changed

.github/workflows/gradle-build.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
uses: actions/setup-java@v3
1111
with:
1212
java-version: 11
13-
distribution: 'temurin'
13+
distribution: temurin
1414

1515
- name: Validate Gradle wrapper
1616
uses: gradle/wrapper-validation-action@v1
@@ -19,6 +19,4 @@ jobs:
1919
uses: gradle/gradle-build-action@v2
2020

2121
- name: Build with Gradle
22-
run: ./gradlew build
23-
env:
24-
ADDITIONAL_TEST_RUNS_ON_JVM_VERSIONS: 17,18
22+
run: ./gradlew build

.github/workflows/publish-to-github-packages.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Publish Snapshot to GitHub Packages
22
on:
33
workflow_run:
4-
workflows: ["Scans"]
4+
workflows: [Scans]
55
branches: [main]
66
types: [completed]
77
jobs:
@@ -16,8 +16,8 @@ jobs:
1616

1717
- uses: actions/setup-java@v3
1818
with:
19-
java-version: '11'
20-
distribution: 'temurin'
19+
java-version: 11
20+
distribution: temurin
2121

2222
- name: Validate Gradle wrapper
2323
uses: gradle/wrapper-validation-action@v1

.github/workflows/publish-to-ossrh.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Publish Snapshot to OSSRH
22
on:
33
workflow_run:
4-
workflows: ["Scans"]
4+
workflows: [Scans]
55
branches: [main]
66
types: [completed]
77
jobs:
@@ -16,8 +16,8 @@ jobs:
1616

1717
- uses: actions/setup-java@v3
1818
with:
19-
java-version: '11'
20-
distribution: 'temurin'
19+
java-version: 11
20+
distribution: temurin
2121

2222
- name: Validate Gradle wrapper
2323
uses: gradle/wrapper-validation-action@v1

.github/workflows/release-to-github-packages.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313

1414
- uses: actions/setup-java@v3
1515
with:
16-
java-version: '11'
17-
distribution: 'temurin'
16+
java-version: 11
17+
distribution: temurin
1818

1919
- name: Validate Gradle wrapper
2020
uses: gradle/wrapper-validation-action@v1

.github/workflows/release-to-ossrh.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313

1414
- uses: actions/setup-java@v3
1515
with:
16-
java-version: '11'
17-
distribution: 'temurin'
16+
java-version: 11
17+
distribution: temurin
1818

1919
- name: Validate Gradle wrapper
2020
uses: gradle/wrapper-validation-action@v1

CONTRIBUTING.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Contributing Guidelines
2+
3+
First of all, thank you for having the interest in contributing to this project!
4+
5+
## Found a bug?
6+
7+
Please create an issue describing the following:
8+
9+
- The version the bug was discovered.
10+
- A scenario to reproduce the bug.
11+
12+
## Enhancement ideas?
13+
14+
Got an idea to enhance the library? Please feel free to create an issue describing the feature proposal. Any ideas are welcome! :)
15+
16+
## Build
17+
18+
The project uses Java 11 as runtime for Gradle but compiles source code to Java 8.
19+
20+
To build the project, run the command:
21+
22+
```sh
23+
./gradlew clean build
24+
```
25+
26+
To create reports, run the commands:
27+
28+
```sh
29+
./gradlew clean build testAggregateTestReport
30+
```
31+
32+
```sh
33+
./gradlew clean build testCodeCoverageReport
34+
```
35+
36+
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`.
37+
38+
## Development Guidelines
39+
40+
### Unit Test Structure
41+
42+
Unit tests in this project follow a specific structure.
43+
44+
- 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.
45+
- 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.
46+
47+
```java
48+
// Class under test: io.github.joeljeremy7.externalizedproperties.resolver.my.MyResolver
49+
class MyResolver implements Resolver {
50+
public MyResolver(...) {
51+
...
52+
}
53+
54+
public Optional<String> resolve(InvocationContext context, String propertyName) {
55+
...
56+
}
57+
58+
public String someOtherMethod(...) {
59+
...
60+
}
61+
62+
public static class Builder {
63+
...
64+
public MyResolver build() {
65+
...
66+
}
67+
}
68+
}
69+
70+
// Test class: io.github.joeljeremy7.externalizedproperties.resolver.my.MyResolverTests
71+
class MyResolverTests {
72+
@Nested
73+
class Constructor {
74+
// @Test methods here...
75+
}
76+
77+
@Nested
78+
class ResolveMethod {
79+
// @Test methods here...
80+
}
81+
82+
@Nested
83+
class SomeOtherMethod {
84+
// @Test methods here...
85+
}
86+
87+
// Nested class must also have corresponding test classes
88+
@Nested
89+
class BuilderTests {
90+
...
91+
@Nested
92+
class BuildMethod {
93+
// @Test methods here...
94+
}
95+
}
96+
}
97+
```

build.gradle

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,8 @@ configure(javaProjects) {
3939
apply from: "${rootDir}/gradle/code-quality.gradle"
4040
apply from: "${rootDir}/gradle/multi-jvm-tests.gradle"
4141

42-
dependencies {
43-
testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}"
44-
}
45-
4642
testing {
47-
suites {
48-
test {
49-
useJUnitJupiter()
50-
}
43+
suites {
5144
integrationTest(JvmTestSuite) {
5245
testType = TestSuiteType.INTEGRATION_TEST
5346
targets {
@@ -59,10 +52,9 @@ configure(javaProjects) {
5952
}
6053
}
6154
}
62-
}
63-
64-
compileJava {
65-
options.release = 11
55+
suites.configureEach {
56+
useJUnitJupiter("${versions.junitJupiter}")
57+
}
6658
}
6759

6860
java {
@@ -73,6 +65,11 @@ configure(javaProjects) {
7365
}
7466
}
7567

68+
tasks.withType(JavaCompile).configureEach {
69+
// For some reason, options.release flag doesn't work with compileJava.
70+
options.release = 8
71+
}
72+
7673
javadoc {
7774
configure(options) {
7875
tags(

core/src/main/java/io/github/joeljeremy7/externalizedproperties/core/ConversionResult.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ public T value() {
9595
return value;
9696
}
9797

98-
/** {@inheritDoc}} */
98+
/** {@inheritDoc} */
9999
@Override
100100
public int hashCode() {
101101
return Objects.hashCode(value);
102102
}
103103

104-
/** {@inheritDoc}} */
104+
/** {@inheritDoc} */
105105
@Override
106106
public boolean equals(Object obj) {
107107
if (this == obj) {

core/src/main/java/io/github/joeljeremy7/externalizedproperties/core/Converter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ default ConversionResult<T> convert(
5353
*
5454
* @param context The invocation context.
5555
* @param valueToConvert The value to convert.
56-
* @param targetType The target type of the conversion.
56+
* @param targetType The target type of the conversion. In the case of converter facades
57+
* (see {@link ConverterFacade}), target type may be different from the invoked proxy
58+
* method's return type.
5759
* @return The result of conversion to the target type or {@link ConversionResult#skip()}
5860
* if the converter cannot handle conversion to the target type and that the conversion
5961
* process should skip/move to the next registered converter in the conversion pipeline.

core/src/main/java/io/github/joeljeremy7/externalizedproperties/core/Ordinals.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private OrdinalResolver(int ordinal, Resolver decorated) {
166166
this.decorated = requireNonNull(decorated, "decorated");
167167
}
168168

169-
/** {@inheritDoc}} */
169+
/** {@inheritDoc} */
170170
@Override
171171
public Optional<String> resolve(InvocationContext context, String propertyName) {
172172
return decorated.resolve(context, propertyName);
@@ -212,13 +212,13 @@ public OrdinalConverter(int ordinal, Converter<T> decorated) {
212212
this.decorated = requireNonNull(decorated, "decorated");;
213213
}
214214

215-
/** {@inheritDoc}} */
215+
/** {@inheritDoc} */
216216
@Override
217217
public boolean canConvertTo(Class<?> targetType) {
218218
return decorated.canConvertTo(targetType);
219219
}
220220

221-
/** {@inheritDoc}} */
221+
/** {@inheritDoc} */
222222
@Override
223223
public ConversionResult<T> convert(
224224
InvocationContext context,

0 commit comments

Comments
 (0)