Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrubbers not enabled for verifyXml #132

Open
emilybache opened this issue Jan 8, 2021 · 2 comments
Open

Scrubbers not enabled for verifyXml #132

emilybache opened this issue Jan 8, 2021 · 2 comments
Labels

Comments

@emilybache
Copy link
Contributor

emilybache commented Jan 8, 2021

I have this exercise where I'm using verifyXml:

github.com/emilybache/Product-Export-Refactoring-Kata

If you look at the 'with_tests' branch in the java version the fourth test 'exportHistory' works and passes with this code:

@Test
    public void exportHistory() throws Exception {
        Collection<Order> orders = Arrays.asList(RecentOrder, OldOrder);
        String xml = XMLExporter.exportHistory(orders);
        String regex = "createdAt='[^']+'";
        xml = xml.replaceFirst(regex, "createdAt='2018-09-20T00:00Z'");
        Approvals.verifyXml(xml);
    }

I would like to be able to use a scrubber like this:

    Approvals.verifyXml(xml, new Options(new RegExScrubber("createdAt='[^']+'", "createdAt='2018-09-20T00:00Z'")));

Unfortunately that code does not work.

@LarsEckart LarsEckart self-assigned this Jan 9, 2021
@LarsEckart
Copy link
Contributor

I investigated a bit.
The problem is that we transform&pretty-print the input string before applying the scrubber and this step changes the ' to ".
So by the time we scrub, the pattern doesn't find any matches anymore.

I wrote a quick fix and will discuss it with @isidore on Monday night. :)

@LarsEckart LarsEckart added the bug label Jan 9, 2021
@emilybache
Copy link
Contributor Author

Thankyou! I hadn't realized the regex could be adjusted to make this actually work. I guess what I'd really like is for an xml aware scrubber that you could give an xpath and it would scrub the piece of xml the xpath refers to. Since we're parsing the xml in order to pretty print it, I would have thought this should be possible?

@LarsEckart LarsEckart removed their assignment Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants