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

Commit

Permalink
Remove test-related methods from DocumentDAO
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Oct 19, 2012
1 parent 4f4847e commit bbb3363
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
16 changes: 0 additions & 16 deletions zanata-war/src/main/java/org/zanata/dao/DocumentDAO.java
Expand Up @@ -22,7 +22,6 @@
import org.zanata.model.HDocument;
import org.zanata.model.HProjectIteration;
import org.zanata.model.HRawDocument;
import org.zanata.model.HTextFlow;
import org.zanata.model.StatusCount;

@Name("documentDAO")
Expand Down Expand Up @@ -304,21 +303,6 @@ public Map<LocaleId, TranslationStats> getStatistics(long docId, LocaleId ... lo
return returnStats;
}

public void syncRevisions(HDocument doc, HTextFlow... textFlows)
{
int rev = doc.getRevision();
syncRevisions(doc, rev, textFlows);
}

public void syncRevisions(HDocument doc, int revision, HTextFlow... textFlows)
{
doc.setRevision(revision);
for (HTextFlow textFlow : textFlows)
{
textFlow.setRevision(revision);
}
}

public HDocument getByProjectIterationAndDocId(final String projectSlug, final String iterationSlug, final String docId)
{
Session session = getSession();
Expand Down
22 changes: 17 additions & 5 deletions zanata-war/src/test/java/org/zanata/model/DocumentJPATest.java
Expand Up @@ -19,14 +19,12 @@
import org.zanata.ZanataDbunitJpaTest;
import org.zanata.common.ContentType;
import org.zanata.common.LocaleId;
import org.zanata.dao.DocumentDAO;
import org.zanata.dao.LocaleDAO;

@Test(groups = { "jpa-tests" })
public class DocumentJPATest extends ZanataDbunitJpaTest
{

private DocumentDAO dao;
private LocaleDAO localeDAO;
HLocale en_US;
HLocale de_DE;
Expand All @@ -37,6 +35,21 @@ protected void prepareDBUnitOperations()
beforeTestOperations.add(new DataSetOperation("org/zanata/test/model/LocalesData.dbunit.xml", DatabaseOperation.CLEAN_INSERT));
}

public void syncRevisions(HDocument doc, HTextFlow... textFlows)
{
int rev = doc.getRevision();
syncRevisions(doc, rev, textFlows);
}

private void syncRevisions(HDocument doc, int revision, HTextFlow... textFlows)
{
doc.setRevision(revision);
for (HTextFlow textFlow : textFlows)
{
textFlow.setRevision(revision);
}
}

@BeforeClass
void beforeClass()
{
Expand All @@ -46,7 +59,6 @@ void beforeClass()
@BeforeMethod(firstTimeOnly = true)
public void beforeMethod()
{
dao = new DocumentDAO((Session) getEm().getDelegate());
localeDAO = new LocaleDAO((Session) em.getDelegate());
en_US = localeDAO.findByLocaleId(LocaleId.EN_US);
de_DE = localeDAO.findByLocaleId(new LocaleId("de"));
Expand Down Expand Up @@ -99,7 +111,7 @@ public void checkPositionsNotNull() throws Exception

textFlows2.remove(flow1);
flow1.setObsolete(true);
dao.syncRevisions(hdoc, flow1);
syncRevisions(hdoc, flow1);

// flow1.setPos(null);
em.flush();
Expand Down Expand Up @@ -143,7 +155,7 @@ public void ensureHistoryOnTextFlow()

flow1.setContents("nwe content!");

dao.syncRevisions(hdoc, flow1);
syncRevisions(hdoc, flow1);

em.flush();

Expand Down

0 comments on commit bbb3363

Please sign in to comment.