Skip to content

Conversation

@RVRhub
Copy link
Contributor

@RVRhub RVRhub commented Nov 10, 2022

The PR introduces XML transformer.
An example of usage

Faker faker = new Faker();
System.out.println(
    new XmlTransformer.XmlTransformerBuilder<Name>().pretty(true).build()
        .generate(faker.<Name>collection().suppliers(faker::name).maxLen(1).build(),
                Schema.of(field("root",() -> Arrays.asList(field("firstName", Name::firstName), field("username", Name::username))))));

Result:

<root>
    <firstName>Danial</firstName>
    <username>arden.little</username>
</root>

Comment on lines 204 to 205
worknumbers: [(715) 228-3360 x9556, (936) 907-6813 x7053]
cellphones: [410.609.5559, 1-720-415-7634, 786-631-7588]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm...
that's not good it should generate
like

name: Katharyn
lastname: Predovic
phones:
  worknumbers: 
     - (715) 228-3360 x9556
     - (936) 907-6813 x7053
  cellphones: 
     - 410.609.5559
     - 1-720-415-7634
     - 786-631-7588

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right.

@codecov-commenter
Copy link

codecov-commenter commented Nov 10, 2022

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 92.13483% with 7 lines in your changes missing coverage. Please review.

Project coverage is 92.61%. Comparing base (2015bcb) to head (904850b).
Report is 1174 commits behind head on main.

Files with missing lines Patch % Lines
.../net/datafaker/transformations/XmlTransformer.java 92.13% 4 Missing and 3 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #549      +/-   ##
============================================
- Coverage     92.66%   92.61%   -0.05%     
- Complexity     2374     2405      +31     
============================================
  Files           248      249       +1     
  Lines          4951     5040      +89     
  Branches        530      543      +13     
============================================
+ Hits           4588     4668      +80     
- Misses          241      246       +5     
- Partials        122      126       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bodiam
Copy link
Contributor

bodiam commented Nov 12, 2022

@snuyanzin can this be merged?

Comment on lines 84 to 90
Field<IN, ?> content = Arrays.stream(attrs)
.filter(inField -> !isAttribute(inField.getName())).findFirst()
.orElse(null);
applyTag(input, sb, content, tag);
} else {
applyTag(input, sb, xmlNode, tag);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could a bit simpler like

Suggested change
Field<IN, ?> content = Arrays.stream(attrs)
.filter(inField -> !isAttribute(inField.getName())).findFirst()
.orElse(null);
applyTag(input, sb, content, tag);
} else {
applyTag(input, sb, xmlNode, tag);
}
xmlNode = Arrays.stream(attrs)
.filter(inField -> !isAttribute(inField.getName())).findFirst()
.orElse(null);
}
applyTag(input, sb, xmlNode, tag);

@snuyanzin
Copy link
Collaborator

in general lgtm
thanks for your contribution @RVRhub
there is just a nit comment
could you fix it please and then we will merge it?

@bodiam
Copy link
Contributor

bodiam commented Nov 14, 2022

Thanks for this change! Time to release I think!!

@bodiam bodiam merged commit 3272c82 into datafaker-net:main Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants