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

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Jul 26, 2013
1 parent 4eea3ef commit 49a5fcf
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 159 deletions.
Expand Up @@ -126,7 +126,6 @@ Document writeToXmlWithValidation(StreamingOutput output) throws IOException, SA
output.write(writerOutputStream);
writerOutputStream.close();
String xml = sbWriter.toString();
System.out.println(xml);
assertValidTMX(xml);
Document doc = XMLUnit.buildControlDocument(xml);
return doc;
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.zanata.ZanataDbunitJpaTest;
import org.zanata.common.LocaleId;
import org.zanata.model.HLocale;
import org.zanata.model.HTextFlow;
import org.zanata.model.HTextFlowTarget;
import org.zanata.seam.SeamAutowire;
import org.zanata.security.ZanataIdentity;
Expand All @@ -30,7 +31,6 @@
import org.zanata.service.ValidationService;
import org.zanata.service.impl.TranslationMemoryQueryServiceImpl;
import org.zanata.service.impl.TranslationStateCacheImpl;
import org.zanata.service.impl.ValidationServiceImpl;
import org.zanata.webtrans.shared.model.TransMemoryQuery;
import org.zanata.webtrans.shared.rpc.GetTranslationMemory;
import org.zanata.webtrans.shared.rpc.GetTranslationMemoryResult;
Expand Down Expand Up @@ -102,12 +102,8 @@ public void testExecute() throws Exception
HTextFlowTarget tmMatch1 = getEm().find(HTextFlowTarget.class, 60L);
HTextFlowTarget tmMatch2 = getEm().find(HTextFlowTarget.class, 62L);

// Note: Different method calls and return types are used depending whether source or target
// index implementation is used
List<Object[]> targetMatches = Lists.newArrayList(new Object[] {1.0F, tmMatch1}, new Object[] {1.1F, tmMatch2});
doReturn(targetMatches).when(translationMemoryQueryService).getSearchResult(eq(query), eq(sourceLocaleId), eq(targetLocaleId), eq(EXPECTED_MAX_RESULTS));
List<Object[]> textFlowMatches = Lists.newArrayList(new Object[] {1.0F, tmMatch1.getTextFlow()}, new Object[] {1.1F, tmMatch2.getTextFlow()});
doReturn(textFlowMatches).when(translationMemoryQueryService).getSearchResult(eq(query), eq(sourceLocaleId), eq(targetLocaleId), eq(EXPECTED_MAX_RESULTS));

GetTranslationMemory action = new GetTranslationMemory(query, targetLocaleId, sourceLocaleId);

Expand All @@ -121,25 +117,23 @@ public void testExecute() throws Exception
assertThat(result.getMemories().get(1).getTargetContents(), Matchers.contains("%d files removed"));
}

// This does not apply to the source index based implementation, but is left in
// case a return to the other implementation is required.
// @Test
// public void searchReturnNotApprovedResult() throws Exception
// {
// // Given: hibernate search finds 2 matches for query and they are not approved translation
// TransMemoryQuery query = new TransMemoryQuery(Lists.newArrayList("file removed"), HasSearchType.SearchType.FUZZY_PLURAL);
// HTextFlow tmMatch1 = getEm().find(HTextFlowTarget.class, 61L).getTextFlow();
// List<Object[]> matches = Lists.newArrayList(new Object[] {1.0F, tmMatch1}, new Object[] {1.1F, null});
// doReturn(matches).when(textFlowDAOSpy).getSearchResult(eq(query), anyList(), eq(sourceLocaleId), eq(targetLocaleId), eq(EXPECTED_MAX_RESULTS));
// GetTranslationMemory action = new GetTranslationMemory(query, targetLocaleId, sourceLocaleId);
//
// // When:
// GetTranslationMemoryResult result = handler.execute(action, null);
//
// // Then:
// verify(identity).checkLoggedIn();
// assertThat(result.getMemories(), Matchers.hasSize(0));
// }
@Test
public void searchReturnNotApprovedResult() throws Exception
{
// Given: hibernate search finds 2 matches for query and they are not approved translation
TransMemoryQuery query = new TransMemoryQuery(Lists.newArrayList("file removed"), HasSearchType.SearchType.FUZZY_PLURAL);
HTextFlow tmMatch1 = getEm().find(HTextFlowTarget.class, 61L).getTextFlow();
List<Object[]> matches = Lists.newArrayList(new Object[] {1.0F, tmMatch1}, new Object[] {1.1F, null});
doReturn(matches).when(translationMemoryQueryService).getSearchResult(eq(query), eq(sourceLocaleId), eq(targetLocaleId), eq(EXPECTED_MAX_RESULTS));
GetTranslationMemory action = new GetTranslationMemory(query, targetLocaleId, sourceLocaleId);

// When:
GetTranslationMemoryResult result = handler.execute(action, null);

// Then:
verify(identity).checkLoggedIn();
assertThat(result.getMemories(), Matchers.hasSize(0));
}

@SuppressWarnings("unchecked")
@Test
Expand Down

0 comments on commit 49a5fcf

Please sign in to comment.