Reputation: 6543
I´v just migrated to a newer version of JUnit where Assert.assertNotEquals has been removed so now i´m struggling to rewrite a test.
Original code:
Double givenLongitude = new Double(13);
assertNotEquals(givenLongitude, extract("position.longitude", eventDataJson, Float.class), 0.01d);
Where the extract method is a generic method that returns Float in this case.
My problem is that I would like to use Assert.assertFalse like this
Double givenLongitude = new Double(13);
assertFalse(givenLongitude.equals(extract("position.longitude", eventDataJson, Float.class)), 0.01d);
But since the assertFalse doesnt have a delta value i´m not sure how to accomplish this without losing the delta value in the comparison? Any suggestions?
Upvotes: 1
Views: 896
Reputation: 6667
Move up to version 4.11. The assertNotEquals methods were reintroduced in this version.
Upvotes: 1
Reputation: 115378
I believe that the prototype of extract method looks like the following:
<T> T extract(String s, .... /*more parameters*/)
In this case you can call it as following:
<Float>extract("position.longitude", eventDataJson, Float.class)
So, I guess you can do:
<Float>extract("position.longitude", eventDataJson, Float.class).floatValue()
If this is compiled you can use assertEquals(float, float, float)
Anyway you can always create special variable and assign value returned from extract
:
float actual = extract(......);
assertEquals(expected, actual);
Upvotes: 0