<commit_before>package org.zanata.webtrans.client.presenter;

import static org.easymock.EasyMock.*;

import net.customware.gwt.presenter.client.EventBus;

import org.easymock.Capture;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.zanata.webtrans.client.events.TransMemoryShorcutCopyHandler;
import org.zanata.webtrans.client.events.TransMemoryShortcutCopyEvent;
import org.zanata.webtrans.client.events.TransUnitSelectionEvent;
import org.zanata.webtrans.client.events.TransUnitSelectionHandler;
import org.zanata.webtrans.client.presenter.TransMemoryPresenter.Display;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
import org.zanata.webtrans.shared.model.TranslationMemoryGlossaryItem;
import org.zanata.webtrans.shared.model.WorkspaceContext;
import org.zanata.webtrans.shared.rpc.GetTranslationMemory.SearchType;

import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.view.client.ListDataProvider;


@Test(groups = { "unit-tests" })
public class TransMemoryPresenterTest
{
   // object under test
   TransMemoryPresenter transMemoryPresenter;

   //injected mocks
   Display mockDisplay = createMock(Display.class);
   EventBus mockEventBus = createMock(EventBus.class);
   CachingDispatchAsync mockDispatcher = createMock(CachingDispatchAsync.class);
   TransMemoryDetailsPresenter mockTransMemoryDetailsPresenter = createMock(TransMemoryDetailsPresenter.class);
   WorkspaceContext mockWorkspaceContext = createMock(WorkspaceContext.class);

   @SuppressWarnings("unchecked")
   HasValue<SearchType> mockSearchType = createMock(HasValue.class);
   HasClickHandlers mockSearchButton = createMock(HasClickHandlers.class);
   @SuppressWarnings("unchecked")
   Column<TranslationMemoryGlossaryItem, ImageResource> mockDetailsColumn = createMock(Column.class);
   @SuppressWarnings("unchecked")
   Column<TranslationMemoryGlossaryItem, String> mockCopyColumn = createMock(Column.class);

   Capture<TransUnitSelectionHandler> capturedTransUnitSelectionEventHandler = new Capture<TransUnitSelectionHandler>();
   Capture<ClickHandler> capturedClearButtonClickHandler = new Capture<ClickHandler>();
   Capture<ClickHandler> capturedSearchButtonClickHandler = new Capture<ClickHandler>();
   Capture<TransMemoryShorcutCopyHandler> capturedTransMemoryShortcutCopyEventHandler = new Capture<TransMemoryShorcutCopyHandler>();

   HasClickHandlers mockClearButton = createMock(HasClickHandlers.class);



   @BeforeMethod
   public void resetMocks()
   {
      reset(mockDispatcher, mockDisplay, mockEventBus, mockTransMemoryDetailsPresenter, mockWorkspaceContext);
      reset(mockSearchType, mockSearchButton, mockClearButton);
      reset(mockDetailsColumn, mockCopyColumn);

      capturedTransUnitSelectionEventHandler.reset();
      capturedSearchButtonClickHandler.reset();
      capturedTransMemoryShortcutCopyEventHandler.reset();
   }

   public void canBind()
   {
      expect(mockDisplay.getSearchType()).andReturn(mockSearchType).anyTimes();<commit_msg>suppress warnings for TM presenter test<commit_after>package org.zanata.webtrans.client.presenter;

import static org.easymock.EasyMock.*;

import net.customware.gwt.presenter.client.EventBus;

import org.easymock.Capture;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.zanata.webtrans.client.events.TransMemoryShorcutCopyHandler;
import org.zanata.webtrans.client.events.TransMemoryShortcutCopyEvent;
import org.zanata.webtrans.client.events.TransUnitSelectionEvent;
import org.zanata.webtrans.client.events.TransUnitSelectionHandler;
import org.zanata.webtrans.client.presenter.TransMemoryPresenter.Display;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
import org.zanata.webtrans.shared.model.TranslationMemoryGlossaryItem;
import org.zanata.webtrans.shared.model.WorkspaceContext;
import org.zanata.webtrans.shared.rpc.GetTranslationMemory.SearchType;

import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.view.client.ListDataProvider;


@Test(groups = { "unit-tests" })
public class TransMemoryPresenterTest
{
   // object under test
   TransMemoryPresenter transMemoryPresenter;

   //injected mocks
   Display mockDisplay = createMock(Display.class);
   EventBus mockEventBus = createMock(EventBus.class);
   CachingDispatchAsync mockDispatcher = createMock(CachingDispatchAsync.class);
   TransMemoryDetailsPresenter mockTransMemoryDetailsPresenter = createMock(TransMemoryDetailsPresenter.class);
   WorkspaceContext mockWorkspaceContext = createMock(WorkspaceContext.class);

   @SuppressWarnings("unchecked")
   HasValue<SearchType> mockSearchType = createMock(HasValue.class);
   HasClickHandlers mockSearchButton = createMock(HasClickHandlers.class);
   @SuppressWarnings("unchecked")
   Column<TranslationMemoryGlossaryItem, ImageResource> mockDetailsColumn = createMock(Column.class);
   @SuppressWarnings("unchecked")
   Column<TranslationMemoryGlossaryItem, String> mockCopyColumn = createMock(Column.class);

   Capture<TransUnitSelectionHandler> capturedTransUnitSelectionEventHandler = new Capture<TransUnitSelectionHandler>();
   Capture<ClickHandler> capturedClearButtonClickHandler = new Capture<ClickHandler>();
   Capture<ClickHandler> capturedSearchButtonClickHandler = new Capture<ClickHandler>();
   Capture<TransMemoryShorcutCopyHandler> capturedTransMemoryShortcutCopyEventHandler = new Capture<TransMemoryShorcutCopyHandler>();

   HasClickHandlers mockClearButton = createMock(HasClickHandlers.class);



   @BeforeMethod
   public void resetMocks()
   {
      reset(mockDispatcher, mockDisplay, mockEventBus, mockTransMemoryDetailsPresenter, mockWorkspaceContext);
      reset(mockSearchType, mockSearchButton, mockClearButton);
      reset(mockDetailsColumn, mockCopyColumn);

      capturedTransUnitSelectionEventHandler.reset();
      capturedSearchButtonClickHandler.reset();
      capturedTransMemoryShortcutCopyEventHandler.reset();
   }

   @SuppressWarnings("unchecked")
   public void canBind()
   {
      expect(mockDisplay.getSearchType()).andReturn(mockSearchType).anyTimes();
{'fraction_non_alphanumeric': 0.09116430260047281, 'fraction_numerical': 0.0, 'mean_word_length': 6.982311320754717, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2021267', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1884, 'n_words': 267}