@@ -55,53 +55,58 @@ void adminNodeRegisterManagementGet_shouldReturnNodeRegisters_whenSuperAdminRequ
5555 MockHttpServletRequestBuilder requestBuilder = get (ENDPOINT_URL );
5656 MvcResult mvcResult = mockMvc .perform (requestBuilder ).andExpect (MockMvcResultMatchers .status ().isOk ()).andReturn ();
5757
58- String actualJson = mvcResult .getResponse ().getContentAsString ();
59- String expectedJson = """
60- [
61- {
62- "id": <nodeid>,
63- "courthouse": {
64- "id": 1,
65- "display_name": "Some Courthouse"
66- },
67- "courtroom": {
68- "id": 1,
69- "name": "<courtroom>"
70- },
71- "ip_address": "192.168.1.3",
72- "hostname": "Host1",
73- "mac_address": "00:0a:95:9d:68:21",
74- "node_type": "DAR",
75- "created_at": "<created_at1>",
76- "created_by": <created_by1>
77- },
78- {
79- "id": <nodeid2>,
80- "courthouse": {
81- "id": 2,
82- "display_name": "Some Courthouse"
83- },
84- "courtroom": {
85- "id": 2,
86- "name": "<courtroom2>"
87- },
88- "ip_address": "192.168.1.3",
89- "hostname": "Host1",
90- "mac_address": "00:0a:95:9d:68:21",
91- "node_type": "DAR",
92- "created_at": "<created_at2>",
93- "created_by": <created_by2>
94- }
95- ]
96- """
97- .replace ("<nodeid>" , String .valueOf (nodeRegisterEntity .getNodeId ()))
98- .replace ("<courtroom>" , nodeRegisterEntity .getCourtroom ().getName ())
99- .replace ("<created_at1>" , nodeRegisterEntity .getCreatedDateTime ().toInstant ().atZone (ZoneOffset .UTC ).format (DateTimeFormatter .ISO_INSTANT ))
100- .replace ("<created_by1>" , String .valueOf (nodeRegisterEntity .getCreatedById ()))
101- .replace ("<nodeid2>" , String .valueOf (nodeRegisterEntity2 .getNodeId ()))
102- .replace ("<courtroom2>" , nodeRegisterEntity2 .getCourtroom ().getName ())
103- .replace ("<created_at2>" , nodeRegisterEntity2 .getCreatedDateTime ().toInstant ().atZone (ZoneOffset .UTC ).format (DateTimeFormatter .ISO_INSTANT ))
104- .replace ("<created_by2>" , String .valueOf (nodeRegisterEntity2 .getCreatedById ()));
58+ String actualJson = normalizeTimestamps (mvcResult .getResponse ().getContentAsString ());
59+ String expectedJson = normalizeTimestamps ("""
60+ [
61+ {
62+ "id": <nodeid>,
63+ "courthouse": {
64+ "id": 1,
65+ "display_name": "Some Courthouse"
66+ },
67+ "courtroom": {
68+ "id": 1,
69+ "name": "<courtroom>"
70+ },
71+ "ip_address": "192.168.1.3",
72+ "hostname": "Host1",
73+ "mac_address": "00:0a:95:9d:68:21",
74+ "node_type": "DAR",
75+ "created_at": "<created_at1>",
76+ "created_by": <created_by1>
77+ },
78+ {
79+ "id": <nodeid2>,
80+ "courthouse": {
81+ "id": 2,
82+ "display_name": "Some Courthouse"
83+ },
84+ "courtroom": {
85+ "id": 2,
86+ "name": "<courtroom2>"
87+ },
88+ "ip_address": "192.168.1.3",
89+ "hostname": "Host1",
90+ "mac_address": "00:0a:95:9d:68:21",
91+ "node_type": "DAR",
92+ "created_at": "<created_at2>",
93+ "created_by": <created_by2>
94+ }
95+ ]
96+ """
97+ .replace ("<nodeid>" , String .valueOf (nodeRegisterEntity .getNodeId ()))
98+ .replace ("<courtroom>" , nodeRegisterEntity .getCourtroom ().getName ())
99+ .replace ("<created_at1>" ,
100+ nodeRegisterEntity .getCreatedDateTime ().toInstant ().atZone (ZoneOffset .UTC ).format (
101+ DateTimeFormatter .ISO_INSTANT ))
102+ .replace ("<created_by1>" , String .valueOf (nodeRegisterEntity .getCreatedById ()))
103+ .replace ("<nodeid2>" , String .valueOf (nodeRegisterEntity2 .getNodeId ()))
104+ .replace ("<courtroom2>" , nodeRegisterEntity2 .getCourtroom ().getName ())
105+ .replace ("<created_at2>" ,
106+ nodeRegisterEntity2 .getCreatedDateTime ().toInstant ().atZone (ZoneOffset .UTC ).format (
107+ DateTimeFormatter .ISO_INSTANT ))
108+ .replace ("<created_by2>" , String .valueOf (nodeRegisterEntity2 .getCreatedById ())));
109+
105110 JSONAssert .assertEquals (expectedJson , actualJson , JSONCompareMode .NON_EXTENSIBLE );
106111 }
107112
@@ -120,4 +125,8 @@ void adminNodeRegisterManagementGet_whenNotAuthenticated_shouldReturnForbiddenEr
120125 """ ;
121126 JSONAssert .assertEquals (expectedResponse , actualResponse , JSONCompareMode .NON_EXTENSIBLE );
122127 }
128+
129+ private String normalizeTimestamps (String json ) {
130+ return json .replaceAll ("(\\ d{4}-\\ d{2}-\\ d{2}T\\ d{2}:\\ d{2}:\\ d{2}\\ .\\ d{5})\\ dZ" , "$1Z" );
131+ }
123132}
0 commit comments