Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix broken unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jul 4, 2013
1 parent 7d46737 commit cb71f13
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions zanata-war/src/test/java/org/zanata/dao/TextFlowDAOTest.java
Expand Up @@ -124,18 +124,31 @@ public void canGetTextFlowsByStatus() {
public void canBuildContentStateQuery()
{
// accept all
assertThat(TextFlowDAO.buildContentStateCondition(true, true, true, "tft"), Matchers.equalTo("1"));
assertThat(TextFlowDAO.buildContentStateCondition(false, false, false, "tft"), Matchers.equalTo("1"));
assertThat(TextFlowDAO.buildContentStateCondition(FilterConstraints.keepAll(), "tft"), Matchers.equalTo("1"));
assertThat(TextFlowDAO.buildContentStateCondition(FilterConstraints.keepNone(), "tft"), Matchers.equalTo("1"));

// single status filter
assertThat(TextFlowDAO.buildContentStateCondition(true, false, false, "tft"), Matchers.equalTo("(tft.state=2 or tft.state=3)"));
assertThat(TextFlowDAO.buildContentStateCondition(false, true, false, "tft"), Matchers.equalTo("(tft.state=1 or tft.state=4)"));
assertThat(TextFlowDAO.buildContentStateCondition(false, false, true, "tft"), Matchers.equalTo("(tft.state=0 or tft.state is null)"));
FilterConstraints filterConstraints = FilterConstraints.keepNone();

filterConstraints = filterConstraints.filterByStatus(false, false, true, false, false);
assertThat(TextFlowDAO.buildContentStateCondition(filterConstraints, "tft"), Matchers.equalTo("(tft.state=2 or tft.state=3)"));

filterConstraints = filterConstraints.filterByStatus(false, true, false, false, false);
assertThat(TextFlowDAO.buildContentStateCondition(filterConstraints, "tft"), Matchers.equalTo("(tft.state=1 or tft.state=4)"));

filterConstraints = filterConstraints.filterByStatus(true, false, false, false, false);
assertThat(TextFlowDAO.buildContentStateCondition(filterConstraints, "tft"), Matchers.equalTo("(tft.state=0 or tft.state is null)"));

// two status
assertThat(TextFlowDAO.buildContentStateCondition(true, false, true, "tft"), Matchers.equalTo("(tft.state=2 or tft.state=3 or tft.state=0 or tft.state is null)"));
assertThat(TextFlowDAO.buildContentStateCondition(true, true, false, "tft"), Matchers.equalTo("(tft.state=2 or tft.state=3 or tft.state=1 or tft.state=4)"));
assertThat(TextFlowDAO.buildContentStateCondition(false, true, true, "tft"), Matchers.equalTo("(tft.state=1 or tft.state=4 or tft.state=0 or tft.state is null)"));

filterConstraints = filterConstraints.filterByStatus(true, false, true, false, false);
assertThat(TextFlowDAO.buildContentStateCondition(filterConstraints, "tft"), Matchers.equalTo("(tft.state=2 or tft.state=3 or tft.state=0 or tft.state is null)"));

filterConstraints = filterConstraints.filterByStatus(false, true, true, false, false);
assertThat(TextFlowDAO.buildContentStateCondition(filterConstraints, "tft"), Matchers.equalTo("(tft.state=2 or tft.state=3 or tft.state=1 or tft.state=4)"));

filterConstraints = filterConstraints.filterByStatus(true, true, false, false, false);
assertThat(TextFlowDAO.buildContentStateCondition(filterConstraints, "tft"), Matchers.equalTo("(tft.state=1 or tft.state=4 or tft.state=0 or tft.state is null)"));
}

@Test
Expand Down

0 comments on commit cb71f13

Please sign in to comment.