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

Commit

Permalink
Reformat file: HTextFlowTargetHistoryJPATest
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Mar 31, 2014
1 parent 55b7b1c commit 956e2ae
Showing 1 changed file with 19 additions and 19 deletions.
Expand Up @@ -34,21 +34,21 @@ public void beforeMethod() {
@Override
protected void prepareDBUnitOperations() {
beforeTestOperations.add(new DataSetOperation(
"org/zanata/test/model/ProjectsData.dbunit.xml",
DatabaseOperation.CLEAN_INSERT));
"org/zanata/test/model/ProjectsData.dbunit.xml",
DatabaseOperation.CLEAN_INSERT));
beforeTestOperations.add(new DataSetOperation(
"org/zanata/test/model/LocalesData.dbunit.xml",
DatabaseOperation.CLEAN_INSERT));
"org/zanata/test/model/LocalesData.dbunit.xml",
DatabaseOperation.CLEAN_INSERT));
}

@Test
public void ensureHistoryIsRecorded() {
Session session = getSession();
HDocument d =
new HDocument("/path/to/document.txt", ContentType.TextPlain,
en_US);
new HDocument("/path/to/document.txt", ContentType.TextPlain,
en_US);
d.setProjectIteration((HProjectIteration) session.load(
HProjectIteration.class, 1L));
HProjectIteration.class, 1L));
session.save(d);
session.flush();

Expand All @@ -63,23 +63,23 @@ public void ensureHistoryIsRecorded() {

List<HTextFlowTargetHistory> historyElems = getHistory(target);
assertThat("Incorrect History size on persist", historyElems.size(),
is(0));
is(0));

target.setContents("blah!");
session.flush();

historyElems = getHistory(target);

assertThat("Incorrect History size on first update",
historyElems.size(), is(1));
historyElems.size(), is(1));

target.setContents("hola mundo!");
session.flush();

historyElems = getHistory(target);

assertThat("Incorrect History size on second update",
historyElems.size(), is(2));
historyElems.size(), is(2));
assertThat(historyElems.size(), is(2));
HTextFlowTargetHistory hist = historyElems.get(0);
assertThat(hist.getContents(), is(Arrays.asList("helleu world")));
Expand All @@ -89,10 +89,10 @@ public void ensureHistoryIsRecorded() {
public void ensureHistoryIsRecordedPlural() {
Session session = getSession();
HDocument d =
new HDocument("/path/to/document.txt", ContentType.TextPlain,
en_US);
new HDocument("/path/to/document.txt", ContentType.TextPlain,
en_US);
d.setProjectIteration((HProjectIteration) session.load(
HProjectIteration.class, 1L));
HProjectIteration.class, 1L));
session.save(d);
session.flush();

Expand All @@ -116,21 +116,21 @@ public void ensureHistoryIsRecordedPlural() {
assertThat(historyElems.size(), is(1));
HTextFlowTargetHistory hist = historyElems.get(0);
assertThat(hist.getContents(),
is(Arrays.asList("helleu world", "helleu worlds")));
is(Arrays.asList("helleu world", "helleu worlds")));

assert historyDAO.findContentInHistory(target,
Arrays.asList("helleu world", "helleu worlds"));
Arrays.asList("helleu world", "helleu worlds"));
assert !historyDAO.findContentInHistory(target,
Arrays.asList("helleu world"));
Arrays.asList("helleu world"));
assert !historyDAO.findContentInHistory(target,
Arrays.asList("helleu worlds"));
Arrays.asList("helleu worlds"));
assert !historyDAO.findContentInHistory(target,
Arrays.asList("blah", "blah!"));
Arrays.asList("blah", "blah!"));
}

@SuppressWarnings("unchecked")
private List<HTextFlowTargetHistory> getHistory(HTextFlowTarget tft) {
return getSession().createCriteria(HTextFlowTargetHistory.class)
.add(Restrictions.eq("textFlowTarget", tft)).list();
.add(Restrictions.eq("textFlowTarget", tft)).list();
}
}

0 comments on commit 956e2ae

Please sign in to comment.