Skip to content

Commit

Permalink
fix: parse string with random property order
Browse files Browse the repository at this point in the history
  • Loading branch information
pcvolkmer committed Aug 17, 2024
1 parent acfae16 commit 8a578b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class StructKeyStringSerde implements Serde<StructKey> {

private static final Pattern structPattern =
Pattern.compile(
"Struct\\{(REFERENZ_NUMMER=\"(?<referenznummer>[^\"]*)\")?,?\\s*(TUMOR_ID=\"(?<tumorid>[^\"]*)\")?\\}");
"Struct\\{((REFERENZ_NUMMER=\"(?<referenznummer>[^\"]*)\")|(TUMOR_ID=\"(?<tumorid>[^\"]*))\"|,\\s*)+\\}");

@Override
public Serializer<StructKey> serializer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ void shouldDeserializeStructKey() {
assertThat(actual).isEqualTo(new StructKey("01234", "1"));
}

@Test
void shouldDeserializeStructKeyWithInvertedPropertyOrder() {
var actual =
serde
.deserializer()
.deserialize(
"any",
"Struct{TUMOR_ID=\"1\",REFERENZ_NUMMER=\"01234\"}"
.getBytes(StandardCharsets.UTF_8));
assertThat(actual).isEqualTo(new StructKey("01234", "1"));
}

@Test
void shouldDeserializePartialStructKeyWithRefNumOnly() {
var actual =
Expand Down

0 comments on commit 8a578b2

Please sign in to comment.