diff --git a/zanata-war/src/main/webapp/version-group/version_group.xhtml b/zanata-war/src/main/webapp/version-group/version_group.xhtml
index 194d416217..eacefd5c12 100644
--- a/zanata-war/src/main/webapp/version-group/version_group.xhtml
+++ b/zanata-war/src/main/webapp/version-group/version_group.xhtml
@@ -24,8 +24,8 @@
zanata.tabs.activate(jQuery('#languages_tab'));
var clickEle = jQuery('a.' + lang);
if (lang && clickEle.length != 0) {
- updateActiveRow(clickEle)
- toggleColumn('languages')
+ updateActiveRow(clickEle);
+ toggleColumn('languages');
reloadLocale(lang)
}
});
@@ -33,7 +33,7 @@
crossroads.addRoute(':pre*:/version-group/view/{slug}/projects/{proj}/{ver}',
function (pre, slug, proj, ver) {
zanata.tabs.activate(jQuery('#projects_tab'));
- var clickEle = jQuery('#' + jqSelector(proj + "[" + ver + "]") + " a")
+ var clickEle = jQuery('#' + jqSelector(proj + "[" + ver + "]") + " a");
if (clickEle.length != 0) {
updateActiveRow(clickEle);
toggleColumn('projects');
@@ -53,46 +53,48 @@
crossroads.addRoute(':pre*:/version-group/view/{slug}/:section:',
function (pre, slug, section) {
- section = section || 'languages'
+ section = section || 'languages';
section = validateTab('#' + section + "_tab", section, "languages");
zanata.tabs.activate(jQuery('#' + section + "_tab"))
});
renderStatistics();
- })
+ });
//]]>
-
diff --git a/zanata-war/src/test/java/org/zanata/service/impl/DocumentServiceImplTest.java b/zanata-war/src/test/java/org/zanata/service/impl/DocumentServiceImplTest.java
index 34ab882e54..1253f21ce6 100644
--- a/zanata-war/src/test/java/org/zanata/service/impl/DocumentServiceImplTest.java
+++ b/zanata-war/src/test/java/org/zanata/service/impl/DocumentServiceImplTest.java
@@ -46,6 +46,7 @@
import org.zanata.model.HProjectIteration;
import org.zanata.model.WebHook;
import org.zanata.service.DocumentService;
+import org.zanata.service.TranslationStateCache;
import org.zanata.ui.model.statistic.WordStatistic;
import org.zanata.util.StatisticsUtil;
@@ -63,6 +64,9 @@ public class DocumentServiceImplTest {
@Mock
private DocumentDAO documentDAO;
+ @Mock
+ private TranslationStateCache translationStateCacheImpl;
+
@Mock
private Messages msgs;
@@ -82,7 +86,8 @@ public class DocumentServiceImplTest {
public void setup() {
MockitoAnnotations.initMocks(this);
documentService = new DocumentServiceImpl();
- documentService.init(projectIterationDAO, documentDAO, msgs);
+ documentService.init(projectIterationDAO, documentDAO,
+ translationStateCacheImpl, msgs);
HProjectIteration version = Mockito.mock(HProjectIteration.class);
HProject project = Mockito.mock(HProject.class);
@@ -108,6 +113,8 @@ public void documentMilestoneEventTranslatedTest() {
DocumentServiceImpl spyService = Mockito.spy(documentService);
WordStatistic stats = new WordStatistic(0, 0, 0, 10, 0);
+ when(translationStateCacheImpl.getDocumentStatistics(docId, localeId))
+ .thenReturn(stats);
runDocumentStatisticUpdatedTest(spyService, ContentState.New,
ContentState.Translated, stats);
@@ -128,6 +135,8 @@ public void documentMilestoneEventTranslatedNot100Test() {
DocumentServiceImpl spyService = Mockito.spy(documentService);
WordStatistic stats = new WordStatistic(0, 1, 0, 9, 0);
+ when(translationStateCacheImpl.getDocumentStatistics(docId, localeId))
+ .thenReturn(stats);
runDocumentStatisticUpdatedTest(spyService, ContentState.New,
ContentState.Translated, stats);
@@ -148,6 +157,8 @@ public void documentMilestoneEventApprovedTest() {
DocumentServiceImpl spyService = Mockito.spy(documentService);
WordStatistic stats = new WordStatistic(10, 0, 0, 0, 0);
+ when(translationStateCacheImpl.getDocumentStatistics(docId, localeId))
+ .thenReturn(stats);
runDocumentStatisticUpdatedTest(spyService, ContentState.Translated,
ContentState.Approved, stats);
@@ -167,6 +178,8 @@ public void documentMilestoneEventApprovedNot100Test() {
DocumentServiceImpl spyService = Mockito.spy(documentService);
WordStatistic stats = new WordStatistic(9, 0, 0, 1, 0);
+ when(translationStateCacheImpl.getDocumentStatistics(docId, localeId))
+ .thenReturn(stats);
runDocumentStatisticUpdatedTest(spyService, ContentState.Translated,
ContentState.Approved, stats);
@@ -186,6 +199,8 @@ public void documentMilestoneEventApprovedNot100Test() {
public void documentMilestoneEventSameStateTest1() {
DocumentServiceImpl spyService = Mockito.spy(documentService);
WordStatistic stats = new WordStatistic(10, 0, 0, 0, 0);
+ when(translationStateCacheImpl.getDocumentStatistics(docId, localeId))
+ .thenReturn(stats);
runDocumentStatisticUpdatedTest(spyService, ContentState.Approved,
ContentState.Approved, stats);
@@ -206,8 +221,11 @@ public void documentMilestoneEventSameStateTest2() {
DocumentServiceImpl spyService = Mockito.spy(documentService);
WordStatistic stats = new WordStatistic(0, 0, 0, 10, 0);
+ when(translationStateCacheImpl.getDocumentStatistics(docId, localeId))
+ .thenReturn(stats);
+
runDocumentStatisticUpdatedTest(spyService, ContentState.Translated,
- ContentState.Translated, stats);
+ ContentState.Translated, stats);
DocumentMilestoneEvent milestoneEvent =
new DocumentMilestoneEvent(projectSlug, versionSlug,
@@ -225,13 +243,10 @@ private void runDocumentStatisticUpdatedTest(
ContentState oldState, ContentState newState, WordStatistic stats) {
int wordCount = 10;
- WordStatistic oldStats = StatisticsUtil.copyWordStatistic(stats);
- oldStats.decrement(newState, wordCount);
- oldStats.increment(oldState, wordCount);
DocumentStatisticUpdatedEvent event =
- new DocumentStatisticUpdatedEvent(oldStats, stats, versionId,
- docId, localeId, oldState, newState);
+ new DocumentStatisticUpdatedEvent(versionId,
+ docId, localeId, wordCount, oldState, newState);
spyService.documentStatisticUpdated(event);
}