RegistryWriter { public String generateRegFileContent(AbstractRegistryNode node) { return String.join("\n", "WINE REGISTRY Version 2", ";; Generated by Phoenicis", buildRegTreeString(node)); }  String generateRegFileContent(AbstractRegistryNode node);  }
@Test public void testGenerateRegFile() throws Exception { final String baseLine = "WINE REGISTRY Version 2\n" + ";; Generated by Phoenicis\n" + "\n" + "[A]\n" + "\n" + "[A\\B]\n" + "\n" + "[A\\C]\n" + "\"D\"=hex:128,129,130\n" + "\"E\"=dword:10\n" + "\"F\"=str(2):\"Content\"\n" + "\"G\"=str(7):\"Content2\"\n" + "\"G\"=\"Content3\"\n"; final RegistryWriter registryWriter = new RegistryWriter(); RegistryKey testNodeA = new RegistryKey("A"); RegistryKey testNodeB = new RegistryKey("B"); RegistryKey testNodeC = new RegistryKey("C"); RegistryValue<BinaryValueType> testNodeD = new RegistryValue<>("D", new BinaryValueType(new byte[] { 0, 1, 2 })); RegistryValue<DwordValueType> testNodeE = new RegistryValue<>("E", new DwordValueType(10L)); RegistryValue<ExpandableValueType> testNodeF = new RegistryValue<>("F", new ExpandableValueType("Content")); RegistryValue<MultiStringValueType> testNodeG = new RegistryValue<>("G", new MultiStringValueType("Content2")); RegistryValue<StringValueType> testNodeH = new RegistryValue<>("G", new StringValueType("Content3")); testNodeA.addChild(testNodeB); testNodeA.addChild(testNodeC); testNodeC.addChildren(testNodeD, testNodeE, testNodeF, testNodeG, testNodeH); assertEquals(baseLine, registryWriter.generateRegFileContent(testNodeA)); }
@Test public void testGenerateRegFileRemoveAValue() { final RegistryWriter registryWriter = new RegistryWriter(); AbstractRegistryNode testRemoveNode = new RegistryKey("HKEY_CURRENT_USER").addDeepChildren("test1", "test2", "test3"); ((RegistryKey) testRemoveNode).addChild(new RegistryValue<>("test4", new RemoveValueType())); assertEquals( "WINE REGISTRY Version 2\n" + ";; Generated by Phoenicis\n" + "\n" + "[HKEY_CURRENT_USER\\test1\\test2\\test3]\n" + "\"test4\"=-\n", registryWriter.generateRegFileContent(testRemoveNode)); }