@@ -121,36 +121,6 @@ public static void enableHTTPLogging() {
121121
122122 private static final Gson gson = new Gson ();
123123
124- /**
125- * Creates a JSON string for an item group.
126- *
127- * @param id the group ID
128- * @param name the group display name
129- * @param parentId the parent group ID
130- * @return JSON string representation
131- */
132- private static String itemGroupToJson (String id , String name , String parentId ) {
133- Map <String , Object > dataMap = new HashMap <String , Object >();
134- dataMap .put ("parent_id" , parentId );
135-
136- Map <String , Object > group = new HashMap <String , Object >();
137- group .put ("id" , id );
138- group .put ("name" , name );
139- group .put ("data" , dataMap );
140-
141- return gson .toJson (group );
142- }
143-
144- /**
145- * Generates a unique ID for test data.
146- *
147- * @param prefix the prefix for the ID
148- * @return a unique ID string
149- */
150- private static String generateId (String prefix ) {
151- return prefix + UUID .randomUUID ().toString ().substring (0 , 8 );
152- }
153-
154124 /**
155125 * Creates a temporary JSON file containing an array of items.
156126 * Uses createProductItem() to generate realistic test data.
@@ -262,10 +232,15 @@ public static File createItemGroupsJsonlFile(int count) throws IOException {
262232
263233 StringBuilder sb = new StringBuilder ();
264234 for (int i = 0 ; i < count ; i ++) {
265- String id = generateId ("group" );
266- String name = "Group " + (i + 1 );
267- String parentId = "root" ;
268- sb .append (itemGroupToJson (id , name , parentId )).append ("\n " );
235+ Map <String , Object > dataMap = new HashMap <String , Object >();
236+ dataMap .put ("parent_id" , "root" );
237+
238+ Map <String , Object > group = new HashMap <String , Object >();
239+ group .put ("id" , "group" + UUID .randomUUID ().toString ().substring (0 , 8 ));
240+ group .put ("name" , "Group " + (i + 1 ));
241+ group .put ("data" , dataMap );
242+
243+ sb .append (gson .toJson (group )).append ("\n " );
269244 }
270245
271246 try (FileWriter writer = new FileWriter (file )) {
@@ -298,14 +273,13 @@ public static File createInvalidExtensionFile() throws IOException {
298273 * @throws IOException if file creation fails
299274 */
300275 public static File createNoExtensionFile () throws IOException {
301- File tempFile = File .createTempFile ("items" , ".tmp" );
302- File noExtFile = new File (tempFile .getParent (), "items_" + UUID .randomUUID ().toString ().substring (0 , 8 ));
303- tempFile .renameTo (noExtFile );
304- noExtFile .deleteOnExit ();
276+ String tmpDir = System .getProperty ("java.io.tmpdir" );
277+ File file = new File (tmpDir , "items_" + UUID .randomUUID ().toString ().substring (0 , 8 ));
278+ file .deleteOnExit ();
305279
306- try (FileWriter writer = new FileWriter (noExtFile )) {
280+ try (FileWriter writer = new FileWriter (file )) {
307281 writer .write ("This file has no extension for testing validation." );
308282 }
309- return noExtFile ;
283+ return file ;
310284 }
311285}
0 commit comments