package com.seven10.update_guy;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.seven10.update_guy.manifest.ManifestEntry;

public class ManifestEntryHelpers
{
	public static Map<String, Path> create_entry_folder_list(int roleCount, Path rootFolder)
	{
		Map<String, Path> rvalue = new HashMap<String, Path>();
		for(int i = 1; i < roleCount; i++)
		{
			String key = "role_" + i;
			Path target = rootFolder.resolve(key + ".txt");
			rvalue.put(key,  target);
		}
		return rvalue;
	}
	public static ManifestEntry create_valid_manifest_entry(String testName, int index, Path rootFolder)
	{
		ManifestEntry mve = new ManifestEntry();
		mve.setVersion("v"+ testName + index);
		Map<String, Path> entries = create_entry_folder_list(index, rootFolder);
		entries.forEach((key,value)->mve.addPath(key, value));
		return mve;
	}
	
	public static List<ManifestEntry> create_valid_manifest_entries(String testName, int entryCount,
			Path rootFolder) throws IOException
	{
		List<ManifestEntry> versionEntries = new ArrayList<ManifestEntry>();
		for (int i = 1; i <= entryCount; i++)
		{
			ManifestEntry versionEntry = create_valid_manifest_entry(testName, i, rootFolder);
			versionEntries.add(versionEntry);
		}
		return versionEntries;
	}
	public static List<String> create_subset_of_roles(Map<String, Path> roleMap)
	{
		// filter out keys with odd hashs. This should give us a subset of the keys
		return roleMap.keySet().stream().filter(key->key.hashCode()%2 == 0).collect(Collectors.toList());
	}
	public static Path get_valid_download_file_path()
	{
		return Paths.get("src","test","resources","repoPaths","1.0","file1");
	}

}

@@ -54,16 +54,44 @@
 eption;%0A
+import java.nio.file.Files;%0A
 import j
@@ -109,16 +109,16 @@
 e.Path;%0A
-
 import j
@@ -445,32 +445,51 @@
 Path rootFolder)
+ throws IOException
 %0A%09%7B%0A%09%09Map%3CString
@@ -554,16 +554,17 @@
 = 1; i %3C
+=
  roleCou
@@ -656,16 +656,45 @@
 .txt%22);%0A
+%09%09%09Files.createFile(target);%0A
 %09%09%09rvalu
@@ -734,24 +734,24 @@
  rvalue;%0A%09%7D%0A
-
 %09public stat
@@ -839,16 +839,35 @@
 tFolder)
+ throws IOException
 %0A%09%7B%0A%09%09Ma

one less-than sign should have been LTE. The world ended