I have a unit test for a Java application that needs to compare two JSON strings. I only care about the data, the formatting should be ignored. I was hoping I could use AssertJ, but I can't seem to figure out how. I need to ignore both the whitespace AND the newlines in my assertion. AssertJ has methods 'isEqualToIgnoringNewLines()' and 'isEqualToIgnoringWhitespace()' but I can only use one or the other. There doesn't seem to be any way to combine them to get the desired result.
My workaround for the moment is to strip out the whitespace myself before running the assertion. However, I feel like there should be a way to do this with just assertions. Is there any way to get the kind of assertion I want without having to manipulate the strings first?
I can only offer workaround by using JSONAssert to achieve comparison that ignores whitespaces and newlines for unit test.
Hope this helps!