Skip to content

Commit

Permalink
fix: fix date/date-time tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gkocak-scottlogic committed Mar 29, 2023
1 parent 456a005 commit 4a3808a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion features/src/test/java/com/openapi/forge/MethodCallHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -132,7 +134,13 @@ public String getPropertyOnObject(
Class.forName(packageName + "." + latestResponseType, false, classLoader);
Method getProp = propClass.getDeclaredMethod("get" + StringUtils.capitalize(propName));
getProp.setAccessible(true); // Otherwise causes IllegalAccessException.
return getProp.invoke(resultOfMethodCall).toString();
Object resultObject = getProp.invoke(resultOfMethodCall);
// Default ZonedDateTime formatting doesn't match with ISO format.
if (resultObject instanceof ZonedDateTime) {
return DateTimeFormatter.ISO_INSTANT.format((ZonedDateTime) resultObject);
} else {
return resultObject.toString();
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("This is probably an issue with the test code:\t\r\n" + e);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
Expand Down

0 comments on commit 4a3808a

Please sign in to comment.