@@ -0,0 +1,1924 @@
+package beaform.commands;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.util.concurrent.Callable;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport beaform.dao.FormulaDAO;%0Aimport beaform.dao.GraphDbHandler;%0Aimport beaform.debug.DebugUtils;%0Aimport beaform.entities.Formula;%0Aimport beaform.search.SearchFormulaTask;%0Aimport beaform.utilities.ErrorDisplay;%0A%0Apublic class CommandsTest %7B%0A%0A%09private final ErrorDisplay errorDisplay = new LoggingErrorDisplay();%0A%0A%09@Before%0A%09public void setUp() %7B%0A%09%09GraphDbHandler.initInstanceWithDbPath(%22neo4j_test/db%22);%0A%09%7D%0A%0A%09@Test%0A%09public void testCreateCommand() %7B%0A%09%09final Formula formulaToPersist = new Formula(%22testName%22, %22testDesc%22, %22100g%22);%0A%09%09formulaToPersist.setNotes(%22Testing notes%22);%0A%0A%09%09Command cmd = new CreateNewFormulaCommand(formulaToPersist, this.errorDisplay);%0A%09%09cmd.execute();%0A%0A%09%09final Formula resultingFormula = FormulaDAO.findFormulaByName(%22testName%22);%0A%09%09assertEquals(%22The 2 formulas are not the same%22, formulaToPersist, resultingFormula);%0A%09%7D%0A%0A%09@Test%0A%09public void testUpdateCommand() throws Exception %7B%0A%09%09DebugUtils.fillDb();%0A%09%09final Formula formula = new Formula(%22Form1%22, %22New description%22, %22100g%22);%0A%0A%09%09Command cmd = new UpdateFormulaCommand(formula, this.errorDisplay);%0A%09%09cmd.execute();%0A%0A%09%09final Callable%3CFormula%3E task = new SearchFormulaTask(%22Form1%22);%0A%09%09final Formula result = task.call();%0A%09%09assertEquals(%22This isn't the expected description%22, %22New description%22, result.getDescription());%0A%09%7D%0A%0A%09@After%0A%09public void tearDown() %7B%0A%09%09DebugUtils.clearDb();%0A%09%7D%0A%0A%09private static class LoggingErrorDisplay implements ErrorDisplay %7B%0A%09%09private static final Logger LOG = LoggerFactory.getLogger(LoggingErrorDisplay.class);%0A%0A%09%09public LoggingErrorDisplay() %7B%0A%09%09%09// TODO Auto-generated constructor stub%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void displayError(String error) %7B%0A%09%09%09LOG.info(error);%0A%09%09%7D%0A%0A%09%7D%0A%0A%7D%0A

Add basic tests for the commands