package me.coley.recaf;

import me.coley.recaf.decompile.fernflower.FernFlowerDecompiler;
import me.coley.recaf.workspace.*;
import org.junit.jupiter.api.*;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

public class DecompileTest extends Base {
	private Workspace workspace;

	@BeforeEach
	public void setup() {
		try {
			JavaResource resource = new JarResource(getClasspathFile("inherit.jar"));
			resource.getClasses();
			resource.getResources();
			workspace = new Workspace(resource);
		} catch(IOException ex) {
			fail(ex);
		}
	}


	@Nested
	public class FernFlower {
		@Test
		public void testFernFlower() {
			String className = "test/Yoda";
			FernFlowerDecompiler decompiler = new FernFlowerDecompiler();
			String decomp = decompiler.decompile(workspace, className);
			assertNotNull(decomp);
		}
	}
}

@@ -715,43 +715,8 @@
 ) %7B%0A
-%09%09%09String className = %22test/Yoda%22;%0A
 %09%09%09F
@@ -776,16 +776,75 @@
 iler();%0A
+%09%09%09for (String name : workspace.getPrimaryClassNames()) %7B%0A%09
 %09%09%09Strin
@@ -890,20 +890,16 @@
 ce, 
-classN
+n
 ame);%0A
+%09
 %09%09%09a
@@ -920,16 +920,21 @@
 ecomp);%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%7D%0A%7D

Test for decompile against all classes in the primary resource