01: package liquibase.parser.filter;
02:
03: import liquibase.ChangeSet;
04: import liquibase.RanChangeSet;
05: import static org.junit.Assert.*;
06: import org.junit.Test;
07:
08: import java.util.ArrayList;
09: import java.util.Date;
10:
11: public class ExecutedAfterChangeSetFilterTest {
12:
13: @Test
14: public void accepts_noRan() throws Exception {
15: ExecutedAfterChangeSetFilter filter = new ExecutedAfterChangeSetFilter(
16: new Date(), new ArrayList<RanChangeSet>());
17:
18: assertFalse(filter.accepts(new ChangeSet("1", "testAuthor",
19: false, false, "path/changelog", null, null, null)));
20: }
21:
22: @Test
23: public void accepts_nullDate() throws Exception {
24: ArrayList<RanChangeSet> ranChanges = new ArrayList<RanChangeSet>();
25: ranChanges.add(new RanChangeSet("path/changelog", "1",
26: "testAuthor", "12345", new Date(), null));
27: ranChanges.add(new RanChangeSet("path/changelog", "2",
28: "testAuthor", "12345", null, null));
29: ranChanges.add(new RanChangeSet("path/changelog", "3",
30: "testAuthor", "12345", new Date(), null));
31: ExecutedAfterChangeSetFilter filter = new ExecutedAfterChangeSetFilter(
32: new Date(), ranChanges);
33:
34: assertFalse(filter.accepts(new ChangeSet("1", "testAuthor",
35: false, false, "path/changelog", null, null, null)));
36: }
37:
38: @Test
39: public void accepts() throws Exception {
40: ArrayList<RanChangeSet> ranChanges = new ArrayList<RanChangeSet>();
41: ranChanges.add(new RanChangeSet("path/changelog", "1",
42: "testAuthor", "12345", new Date(new Date().getTime()
43: - 10 * 1000 * 60 * 60), null));
44: ranChanges.add(new RanChangeSet("path/changelog", "2",
45: "testAuthor", "12345", new Date(new Date().getTime()
46: - 8 * 1000 * 60 * 60), null));
47: ranChanges.add(new RanChangeSet("path/changelog", "3",
48: "testAuthor", "12345", new Date(new Date().getTime()
49: - 4 * 1000 * 60 * 60), null));
50: ExecutedAfterChangeSetFilter filter = new ExecutedAfterChangeSetFilter(
51: new Date(new Date().getTime() - 6 * 1000 * 60 * 60),
52: ranChanges);
53:
54: assertFalse(filter.accepts(new ChangeSet("1", "testAuthor",
55: false, false, "path/changelog", null, null, null)));
56: assertFalse(filter.accepts(new ChangeSet("2", "testAuthor",
57: false, false, "path/changelog", null, null, null)));
58: assertTrue(filter.accepts(new ChangeSet("3", "testAuthor",
59: false, false, "path/changelog", null, null, null)));
60:
61: }
62: }
|