01: package liquibase.parser.visitor;
02:
03: import liquibase.ChangeSet;
04: import liquibase.database.Database;
05: import static org.easymock.classextension.EasyMock.*;
06: import org.junit.Test;
07:
08: public class UpdateVisitorTest {
09:
10: @Test
11: public void visit_unrun() throws Exception {
12: Database database = createMock(Database.class);
13:
14: ChangeSet changeSet = createMock(ChangeSet.class);
15: changeSet.execute(database);
16: expectLastCall();
17:
18: expect(database.getRunStatus(changeSet)).andReturn(
19: ChangeSet.RunStatus.NOT_RAN);
20:
21: database.markChangeSetAsRan(changeSet);
22: expectLastCall();
23:
24: database.commit();
25: expectLastCall();
26:
27: replay(changeSet);
28: replay(database);
29:
30: UpdateVisitor visitor = new UpdateVisitor(database);
31: visitor.visit(changeSet);
32:
33: verify(database);
34: verify(changeSet);
35: }
36:
37: @Test
38: public void visit_rerun() throws Exception {
39: ChangeSet changeSet = createMock(ChangeSet.class);
40: Database database = createMock(Database.class);
41:
42: changeSet.execute(database);
43: expectLastCall();
44:
45: expect(database.getRunStatus(changeSet)).andReturn(
46: ChangeSet.RunStatus.ALREADY_RAN);
47:
48: database.markChangeSetAsReRan(changeSet);
49: expectLastCall();
50:
51: database.commit();
52: expectLastCall();
53:
54: replay(changeSet);
55: replay(database);
56:
57: UpdateVisitor visitor = new UpdateVisitor(database);
58: visitor.visit(changeSet);
59:
60: verify(database);
61: verify(changeSet);
62: }
63: }
|