generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
203 additions
and
117 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
26 changes: 26 additions & 0 deletions
26
serde-jackson-tck/src/main/groovy/io/micronaut/serde/jackson/JsonIgnoreSpec.groovy
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
22 changes: 22 additions & 0 deletions
22
serde-jackson-tck/src/main/java/io/micronaut/serde/jackson/tst/AfterCareStatsEntry.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,22 @@ | ||
package io.micronaut.serde.jackson.tst; | ||
|
||
import io.micronaut.core.annotation.Introspected; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
@Introspected | ||
public record AfterCareStatsEntry() implements StatsEntry { | ||
|
||
static List<Aggregation> AFTERCARE_AGGREGATIONS = List.of( | ||
Aggregation.FIELD_1, | ||
Aggregation.FIELD_2 | ||
); | ||
|
||
@Override | ||
public Map<Aggregation, Integer> getShouldNotAppearInJson() { | ||
return AFTERCARE_AGGREGATIONS.stream().collect(Collectors.toMap(it -> it, it -> 0, (x, y) -> y, LinkedHashMap::new)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
serde-jackson-tck/src/main/java/io/micronaut/serde/jackson/tst/Aggregation.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,22 @@ | ||
package io.micronaut.serde.jackson.tst; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import io.micronaut.core.annotation.Introspected; | ||
|
||
@Introspected | ||
public enum Aggregation { | ||
|
||
FIELD_1("SomeField1"), | ||
FIELD_2("SomeField2"); | ||
|
||
private String fieldName; | ||
|
||
Aggregation(String fieldName) { | ||
this.fieldName = fieldName; | ||
} | ||
|
||
@JsonValue | ||
public String getFieldName() { | ||
return fieldName; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
serde-jackson-tck/src/main/java/io/micronaut/serde/jackson/tst/ClassificationAndStats.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,20 @@ | ||
package io.micronaut.serde.jackson.tst; | ||
|
||
import com.fasterxml.jackson.annotation.JsonGetter; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import io.micronaut.core.annotation.Introspected; | ||
|
||
import java.util.Map; | ||
|
||
@Introspected | ||
public record ClassificationAndStats<T extends StatsEntry>( | ||
ClassificationVars klassifisering, | ||
/** Ignore field to avoid double wrapping of values in resulting JSON */ | ||
@JsonIgnore | ||
T stats | ||
) { | ||
@JsonGetter("stats") | ||
Map<Aggregation, Integer> getValues() { | ||
return stats.getShouldNotAppearInJson(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
serde-jackson-tck/src/main/java/io/micronaut/serde/jackson/tst/ClassificationVars.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,9 @@ | ||
package io.micronaut.serde.jackson.tst; | ||
|
||
import io.micronaut.core.annotation.Introspected; | ||
|
||
@Introspected | ||
public record ClassificationVars( | ||
String regionKode | ||
) { | ||
} |
11 changes: 11 additions & 0 deletions
11
serde-jackson-tck/src/main/java/io/micronaut/serde/jackson/tst/MainAggregationVm.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,11 @@ | ||
package io.micronaut.serde.jackson.tst; | ||
|
||
import io.micronaut.core.annotation.Introspected; | ||
|
||
import java.util.List; | ||
|
||
@Introspected | ||
public record MainAggregationVm( | ||
List<ClassificationAndStats<AfterCareStatsEntry>> afterCare | ||
) { | ||
} |
7 changes: 7 additions & 0 deletions
7
serde-jackson-tck/src/main/java/io/micronaut/serde/jackson/tst/StatsEntry.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,7 @@ | ||
package io.micronaut.serde.jackson.tst; | ||
|
||
import java.util.Map; | ||
|
||
public interface StatsEntry { | ||
Map<Aggregation, Integer> getShouldNotAppearInJson(); | ||
} |
1 change: 1 addition & 0 deletions
1
...-jackson/src/test/groovy/io/micronaut/serde/jackson/annotation/SerdeJsonIgnoreSpec.groovy
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
Oops, something went wrong.