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 AlreadyRanChangeSetFilterTest {
12:
13: @Test
14: public void accepts_noneRun() {
15: AlreadyRanChangeSetFilter filter = new AlreadyRanChangeSetFilter(
16: 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() {
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", new Date(), null));
29: AlreadyRanChangeSetFilter filter = new AlreadyRanChangeSetFilter(
30: ranChanges);
31:
32: //everything same
33: assertTrue(filter.accepts(new ChangeSet("1", "testAuthor",
34: false, false, "path/changelog", null, null, null)));
35:
36: //alwaysRun
37: assertTrue(filter.accepts(new ChangeSet("1", "testAuthor",
38: true, false, "path/changelog", null, null, null)));
39:
40: //run on change
41: assertTrue(filter.accepts(new ChangeSet("1", "testAuthor",
42: false, true, "path/changelog", null, null, null)));
43:
44: //different id
45: assertFalse(filter.accepts(new ChangeSet("3", "testAuthor",
46: false, false, "path/changelog", null, null, null)));
47:
48: //different author
49: assertFalse(filter.accepts(new ChangeSet("1", "otherAuthor",
50: false, false, "path/changelog", null, null, null)));
51:
52: //different path
53: assertFalse(filter.accepts(new ChangeSet("1", "testAuthor",
54: false, false, "other/changelog", null, null, null)));
55: }
56: }
|