X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.hibernate%2Fsrc%2Ftest%2Fjava%2Forg%2Fargeo%2Fslc%2Fhibernate%2Fprocess%2FSlcExecutionHibernateTest.java;h=088b69240d7f4dc1b40b720c5a3b2bc075f7f5ab;hb=b811ec0603b1e596f26eee8a5378c6294cba495d;hp=28c7babcde76e73d663d044186f89b0f3f5682b1;hpb=27442cdd51bb92778b33ec6899c376cd7d848eec;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/process/SlcExecutionHibernateTest.java b/runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/process/SlcExecutionHibernateTest.java index 28c7babcd..088b69240 100644 --- a/runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/process/SlcExecutionHibernateTest.java +++ b/runtime/org.argeo.slc.support.hibernate/src/test/java/org/argeo/slc/hibernate/process/SlcExecutionHibernateTest.java @@ -1,12 +1,29 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.hibernate.process; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; -import org.argeo.slc.core.process.SlcExecution; -import org.argeo.slc.core.process.SlcExecutionStep; import org.argeo.slc.dao.process.SlcExecutionDao; import org.argeo.slc.hibernate.unit.HibernateTestCase; +import org.argeo.slc.process.SlcExecution; +import org.argeo.slc.process.SlcExecutionStep; import org.argeo.slc.unit.process.SlcExecutionTestUtils; import org.hibernate.HibernateException; import org.hibernate.Session; @@ -27,6 +44,35 @@ public class SlcExecutionHibernateTest extends HibernateTestCase { assertSlcExecution(slcExec, slcExecPersisted); } + public void testTailSteps() { + SlcExecutionDao dao = getBean(SlcExecutionDao.class); + + SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution(); + int totalStepCount = 20; + for (int i = 0; i < totalStepCount; i++) { + slcExec.getSteps().add(new SlcExecutionStep("Log " + i)); + } + dao.create(slcExec); + + int lastStepsCount = 7; + List firstSteps = dao.tailSteps(slcExec.getUuid(), + lastStepsCount); + assertEquals(lastStepsCount, firstSteps.size()); + + SlcExecutionStep lastStep = firstSteps.get(lastStepsCount - 1); + + List additionalSteps = new ArrayList(); + int additionalStepsCount = 13; + for (int i = 0; i < additionalStepsCount; i++) { + additionalSteps.add(new SlcExecutionStep("Additonal log " + i)); + } + dao.addSteps(slcExec.getUuid(), additionalSteps); + + List lastSteps = dao.tailSteps(slcExec.getUuid(), + lastStep.getUuid()); + assertEquals(additionalStepsCount, lastSteps.size()); + } + public void testModify() { SlcExecutionDao dao = getBean(SlcExecutionDao.class);