@@ -0,0 +1,2241 @@
+package me.coley.recaf;%0A%0Aimport me.coley.recaf.workspace.*;%0Aimport org.junit.jupiter.api.BeforeEach;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport java.io.IOException;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertEquals;%0Aimport static org.junit.jupiter.api.Assertions.fail;%0A%0A/**%0A * Tests for resource history.%0A *%0A * @author Matt %0A */%0Apublic class HistoryTest extends Base %7B%0A%09private JavaResource resource;%0A%0A%09@BeforeEach%0A%09public void setup() %7B%0A%09%09try %7B%0A%09%09%09resource = new JarResource(getClasspathFile(%22inherit.jar%22));%0A%09%09%09resource.getClasses();%0A%09%09%09resource.getResources();%0A%09%09%7D catch(IOException ex) %7B%0A%09%09%09fail(ex);%0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A%09public void testClassCreateSave()%7B%0A%09%09String key = %22test/Yoda%22;%0A%09%09resource.createClassSave(key);%0A%09%09assertEquals(1, resource.getClassHistory(key).size());%0A%09%09resource.createClassSave(key);%0A%09%09assertEquals(2, resource.getClassHistory(key).size());%0A%09%7D%0A%0A%09@Test%0A%09public void testClassRollback()%7B%0A%09%09String key = %22test/Yoda%22;%0A%09%09byte%5B%5D initial = resource.getClasses().get(key);%0A%09%09// Clean save-state%0A%09%09resource.createClassSave(key);%0A%09%09// Set class value to null%0A%09%09resource.getClasses().put(key, null);%0A%09%09// Rollback%0A%09%09byte%5B%5D rolled = resource.getClassHistory(key).pop();%0A%09%09// Assert pop'd value and value in class map are present and the same%0A%09%09assertEquals(initial, rolled);%0A%09%09assertEquals(initial, resource.getClasses().get(key));%0A%09%7D%0A%0A%09@Test%0A%09public void testResourceCreateSave()%7B%0A%09%09String key = %22file%22;%0A%09%09byte%5B%5D initial = new byte%5B%5D %7B1, 2, 3, 4%7D;%0A%09%09resource.getResources().put(key, initial);%0A%09%09resource.createResourceSave(key);%0A%09%09assertEquals(1, resource.getResourceHistory(key).size());%0A%09%09resource.createResourceSave(key);%0A%09%09assertEquals(2, resource.getResourceHistory(key).size());%0A%09%7D%0A%0A%09@Test%0A%09public void testResourceRollback()%7B%0A%09%09String key = %22file%22;%0A%09%09byte%5B%5D initial = new byte%5B%5D %7B1, 2, 3, 4%7D;%0A%09%09resource.getResources().put(key, initial);%0A%09%09// Clean save-state%0A%09%09resource.createResourceSave(key);%0A%09%09// Set resource value to null%0A%09%09resource.getResources().put(key, null);%0A%09%09// Rollback%0A%09%09byte%5B%5D rolled = resource.getResourceHistory(key).pop();%0A%09%09// Assert pop'd value and value in class map are present and the same%0A%09%09assertEquals(initial, rolled);%0A%09%09assertEquals(initial, resource.getResources().get(key));%0A%09%7D%0A%7D%0A

Create tests for History