@@ -184,7 +184,8 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {
184
184
long workspaceId = workspaceComponent .createWorkspace (null );
185
185
186
186
assertEquals (1 , workspaceId );
187
- assertEquals (String .format ("{\" id\" :1,\" name\" :\" Workspace 0001\" ,\" description\" :\" Description\" ,\" revision\" :1,\" lastModifiedDate\" :\" %s\" ,\" configuration\" :{},\" model\" :{},\" documentation\" :{},\" views\" :{\" configuration\" :{\" branding\" :{},\" styles\" :{},\" terminology\" :{}}}}" , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ())), jsonBuffer .toString ());
187
+ assertEquals (String .format ("""
188
+ {"configuration":{},"description":"Description","documentation":{},"id":1,"lastModifiedDate":"%s","model":{},"name":"Workspace 0001","revision":1,"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""" , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ())), jsonBuffer .toString ());
188
189
}
189
190
190
191
@ Test
@@ -263,7 +264,8 @@ public String getWorkspace(long workspaceId, String version) {
263
264
264
265
WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl (dao , "password" );
265
266
String json = workspaceComponent .getWorkspace (1 , "" );
266
- assertEquals ("{\" id\" :1,\" name\" :\" Name\" ,\" description\" :\" Description\" ,\" configuration\" :{},\" model\" :{},\" documentation\" :{},\" views\" :{\" configuration\" :{\" branding\" :{},\" styles\" :{},\" terminology\" :{}}}}" , json );
267
+ assertEquals ("""
268
+ {"configuration":{},"description":"Description","documentation":{},"id":1,"model":{},"name":"Name","views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""" , json );
267
269
}
268
270
269
271
@ Test
@@ -312,15 +314,18 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {
312
314
}
313
315
};
314
316
317
+ String expectedJson = """
318
+ {"configuration":{},"description":"Description","documentation":{},"id":1,"lastModifiedDate":"%s","model":{},"name":"Name","revision":%s,"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""" ;
319
+
315
320
WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl (dao , "" );
316
321
workspaceComponent .putWorkspace (1 , json );
317
- assertEquals (String .format ("{ \" id \" :1, \" name \" : \" Name \" , \" description \" : \" Description \" , \" revision \" :1, \" lastModifiedDate \" : \" %s \" , \" configuration \" :{}, \" model \" :{}, \" documentation \" :{}, \" views \" :{ \" configuration \" :{ \" branding \" :{}, \" styles \" :{}, \" terminology \" :{}}}}" , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ())), jsonBuffer .toString ());
322
+ assertEquals (String .format (expectedJson , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()), "1" ), jsonBuffer .toString ());
318
323
319
324
// and again, to increment the revision
320
325
json = jsonBuffer .toString ();
321
326
jsonBuffer .setLength (0 );
322
327
workspaceComponent .putWorkspace (1 , json );
323
- assertEquals (String .format ("{ \" id \" :1, \" name \" : \" Name \" , \" description \" : \" Description \" , \" revision \" :2, \" lastModifiedDate \" : \" %s \" , \" configuration \" :{}, \" model \" :{}, \" documentation \" :{}, \" views \" :{ \" configuration \" :{ \" branding \" :{}, \" styles \" :{}, \" terminology \" :{}}}}" , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ())), jsonBuffer .toString ());
328
+ assertEquals (String .format (expectedJson , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()), "2" ), jsonBuffer .toString ());
324
329
}
325
330
326
331
@ Test
@@ -344,14 +349,17 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {
344
349
345
350
WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl (dao , "password" );
346
351
workspaceComponent .putWorkspace (1 , json );
347
- assertTrue (jsonBuffer .toString ().startsWith (String .format ("{\" id\" :1,\" name\" :\" Name\" ,\" description\" :\" Description\" ,\" revision\" :1,\" lastModifiedDate\" :\" %s\" ,\" configuration\" :{},\" ciphertext\" " , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()))));
352
+ String pattern = """
353
+ "id":1,"lastModifiedDate":"%s","name":"Name","revision":%s}""" ;
354
+ assertTrue (jsonBuffer .toString ().startsWith ("{\" ciphertext\" :\" " ));
355
+ assertTrue (jsonBuffer .toString ().endsWith (String .format (pattern , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()), "1" )));
348
356
349
357
// and again, to increment the revision
350
358
json = jsonBuffer .toString ();
351
359
jsonBuffer .setLength (0 );
352
360
workspaceComponent .putWorkspace (1 , json );
353
- System . out . println ( jsonBuffer );
354
- assertTrue (jsonBuffer .toString ().startsWith (String .format ("{ \" id \" :1, \" name \" : \" Name \" , \" description \" : \" Description \" , \" revision \" :2, \" lastModifiedDate \" : \" %s \" , \" configuration \" :{}, \" ciphertext \" " , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()))));
361
+ assertTrue ( jsonBuffer . toString (). startsWith ( "{ \" ciphertext \" : \" " ) );
362
+ assertTrue (jsonBuffer .toString ().endsWith (String .format (pattern , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()), "2" )));
355
363
}
356
364
357
365
@ Test
@@ -380,15 +388,17 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {
380
388
381
389
WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl (dao , "" );
382
390
workspaceComponent .putWorkspace (1 , json );
383
- assertTrue (jsonBuffer .toString ().startsWith (String .format ("{\" id\" :1,\" name\" :\" Name\" ,\" description\" :\" Description\" ,\" revision\" :1,\" lastModifiedDate\" :\" %s\" ,\" configuration\" :{},\" ciphertext\" " , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()))));
384
- assertTrue (jsonBuffer .toString ().endsWith ((json .substring (json .indexOf ("ciphertext" )))));
391
+ String pattern = """
392
+ "id":1,"lastModifiedDate":"%s","name":"Name","revision":%s}""" ;
393
+ assertTrue (jsonBuffer .toString ().startsWith ("{\" ciphertext\" :\" " ));
394
+ assertTrue (jsonBuffer .toString ().endsWith (String .format (pattern , DateUtils .formatIsoDate (workspaceMetaData .getLastModifiedDate ()), "1" )));
385
395
386
396
// and again, to increment the revision
387
397
json = jsonBuffer .toString ();
388
398
jsonBuffer .setLength (0 );
389
399
workspaceComponent .putWorkspace (1 , json );
390
- assertTrue (jsonBuffer .toString ().startsWith (String . format ( "{\" id \" :1, \" name \" : \" Name \" , \" description \" : \" Description \" , \" revision \" :2, \" lastModifiedDate \" : \" %s \" , \" configuration \" :{}, \" ciphertext \" " , DateUtils . formatIsoDate ( workspaceMetaData . getLastModifiedDate ())) ));
391
- assertTrue (jsonBuffer .toString ().endsWith (( json . substring ( json . indexOf ( "ciphertext" )) )));
400
+ assertTrue (jsonBuffer .toString ().startsWith ("{\" ciphertext \" :\" " ));
401
+ assertTrue (jsonBuffer .toString ().endsWith (String . format ( pattern , DateUtils . formatIsoDate ( workspaceMetaData . getLastModifiedDate ()), "2" )));
392
402
}
393
403
394
404
@ Test
0 commit comments