+/*\r
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
package org.argeo.slc.hibernate.process;\r
\r
import java.sql.SQLException;\r
+import java.util.ArrayList;\r
import java.util.List;\r
\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionStep;\r
import org.argeo.slc.dao.process.SlcExecutionDao;\r
import org.argeo.slc.hibernate.unit.HibernateTestCase;\r
+import org.argeo.slc.process.SlcExecution;\r
+import org.argeo.slc.process.SlcExecutionStep;\r
import org.argeo.slc.unit.process.SlcExecutionTestUtils;\r
import org.hibernate.HibernateException;\r
import org.hibernate.Session;\r
assertSlcExecution(slcExec, slcExecPersisted);\r
}\r
\r
+ public void testTailSteps() {\r
+ SlcExecutionDao dao = getBean(SlcExecutionDao.class);\r
+\r
+ SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
+ int totalStepCount = 20;\r
+ for (int i = 0; i < totalStepCount; i++) {\r
+ slcExec.getSteps().add(new SlcExecutionStep("Log " + i));\r
+ }\r
+ dao.create(slcExec);\r
+\r
+ int lastStepsCount = 7;\r
+ List<SlcExecutionStep> firstSteps = dao.tailSteps(slcExec.getUuid(),\r
+ lastStepsCount);\r
+ assertEquals(lastStepsCount, firstSteps.size());\r
+\r
+ SlcExecutionStep lastStep = firstSteps.get(lastStepsCount - 1);\r
+\r
+ List<SlcExecutionStep> additionalSteps = new ArrayList<SlcExecutionStep>();\r
+ int additionalStepsCount = 13;\r
+ for (int i = 0; i < additionalStepsCount; i++) {\r
+ additionalSteps.add(new SlcExecutionStep("Additonal log " + i));\r
+ }\r
+ dao.addSteps(slcExec.getUuid(), additionalSteps);\r
+\r
+ List<SlcExecutionStep> lastSteps = dao.tailSteps(slcExec.getUuid(),\r
+ lastStep.getUuid());\r
+ assertEquals(additionalStepsCount, lastSteps.size());\r
+ }\r
+\r
public void testModify() {\r
SlcExecutionDao dao = getBean(SlcExecutionDao.class);\r
\r